Have you coded a block chain for fun?
- Gunroar:Cannon()
- Party member
- Posts: 1143
- Joined: Thu Dec 10, 2020 1:57 am
Re: Have you coded a block chain for fun?
Yeah, that's the link I needed to see to understand a little bit more what blockchain is. Ah, and I meant even possible to implement in love2d.
Re: Have you coded a block chain for fun?
All you need is a timestamp and a cryptographically secure hash function.
Re: Have you coded a block chain for fun?
I have an idea in the back of my mind about a game that runs in a peer-to-peer network (no host). This might be a stock market game or something that happens in real time over a long time. Peers can join the network and then drop out over the space of days.
The world would need to persist over a long time but exchanging the whole database to every peer on every connection or transaction is not doable. A block chain might work so let's practice block chains.
The world would need to persist over a long time but exchanging the whole database to every peer on every connection or transaction is not doable. A block chain might work so let's practice block chains.
Last project:
https://togfox.itch.io/hwarang
A card game that brings sword fighting to life.
Current project:
Idle gridiron. Set team orders then idle and watch: https://togfox.itch.io/idle-gridiron
https://togfox.itch.io/hwarang
A card game that brings sword fighting to life.
Current project:
Idle gridiron. Set team orders then idle and watch: https://togfox.itch.io/idle-gridiron
Re: Have you coded a block chain for fun?
I read that LUA doesn't have native hash but, as you have linked, there are lots of libraries.
Strictly speaking, on a trusted network with gaming friends, is encryption needed?
Strictly speaking, on a trusted network with gaming friends, is encryption needed?
Last project:
https://togfox.itch.io/hwarang
A card game that brings sword fighting to life.
Current project:
Idle gridiron. Set team orders then idle and watch: https://togfox.itch.io/idle-gridiron
https://togfox.itch.io/hwarang
A card game that brings sword fighting to life.
Current project:
Idle gridiron. Set team orders then idle and watch: https://togfox.itch.io/idle-gridiron
Re: Have you coded a block chain for fun?
Here you go, a useless, buggy and insecure implementation of a basic blockchain algorithm.
Please don't ask further questions about this, or they will be coming after me, lol
Edit: This is of course just the basic principles of the algorithm. How to make a distributed blockchain is a different problem. And proof-of-work could be easily added by adding a nonce and putting constraints on what is considered a valid hash value. For example, accept only hash values that start with one or more 0 bytes.
Please don't ask further questions about this, or they will be coming after me, lol
Code: Select all
local function newBlock(head, payload)
local time = os.date()
local blockData = (head and head.hash or '') .. time .. payload
local block = {
time = time,
payload = payload,
hash = love.data.hash('sha256', blockData),
}
if head then head.next = block end
return block
end
local function verifyBlock(block, prev)
local blockData = (prev and prev.hash or '') .. block.time .. block.payload
return love.data.hash('sha256', blockData) == block.hash
end
local function verify(head)
local prev
while head do
print(head.time, head.payload, love.data.encode('string', 'hex', head.hash))
if not verifyBlock(head, prev) then return false end
prev, head = head, head.next
end
return true
end
local chain = newBlock(nil, 'GENESIS BLOCK')
local head = newBlock(chain, 'second block')
head = newBlock(head, 'and a third one')
print("Chain is valid: ", verify(chain) and 'yes' or 'nope')
-- change second block
chain.next.payload = 'block modified!'
-- the basic idea is that a valid hash for the modified block in the middle of the chain is practically impossible to compute
-- because all previous hashes contribute to all subsequent block's hashes
chain.next.hash = love.data.hash('sha256', chain.hash .. chain.next.time .. chain.next.payload)
print("Chain is valid: ", verify(chain) and 'yes' or 'nope')
Re: Have you coded a block chain for fun?
Thanks. I'll keep this one up my sleeve and extend.
Last project:
https://togfox.itch.io/hwarang
A card game that brings sword fighting to life.
Current project:
Idle gridiron. Set team orders then idle and watch: https://togfox.itch.io/idle-gridiron
https://togfox.itch.io/hwarang
A card game that brings sword fighting to life.
Current project:
Idle gridiron. Set team orders then idle and watch: https://togfox.itch.io/idle-gridiron
Re: Have you coded a block chain for fun?
LOL. The funny thing is I don't even care about a blockchain API, I just wanted to have a discussion about the evolution of games with this developing technology. I felt like my post would be blocked if I didn't make it relevant to löve somehow, so I added that question at the end, entirely harmlessly! But apparently that question got someone a bit rattled.Gunroar:Cannon() wrote: ↑Mon Nov 22, 2021 8:57 pm What is blockchain? Like security? Why was Slime all
-----
PS sorry for the off topic reply. This thread has been an interesting read
- slime
- Solid Snayke
- Posts: 3166
- Joined: Mon Aug 23, 2010 6:45 am
- Location: Nova Scotia, Canada
- Contact:
Re: Have you coded a block chain for fun?
The other thread was talking about it in terms that end up being indistinguishable from one of either scammers, money launderers, or ignorant people who are being used by the first two categories to prop up those things (and would place future positive posts in those same categories).Gunroar:Cannon() wrote: ↑Mon Nov 22, 2021 8:57 pm What is blockchain? Like security? Why was Slime all
https://i.kym-cdn.com/entries/icons/ori ... geFace.jpg
The tech is a solution looking for a problem instead of being created to solve a real large-scale technical problem. In the past few years it's been used mostly by people who don't care about the environment to take money from people who don't know better under the guise of technobabble. Those kinds of people are not welcome here.
Because investors buy into the technobabble, it's getting some traction in the industry as a way to take investment money and inflate the dollar value of a temporary currency without creating anything of real value. That doesn't mean games are evolving, it just means people who don't care much about games or the environment but do care about money are using games to get what they want. It probably won't last long.
I understand people might not be as familiar with the topic as I am - but these forums are not a place to entice people who don't know better into it, or to have long-form Q&As about how these scams operate.
Re: Have you coded a block chain for fun?
Well said, slime!
Tools: Hot Particles, LuaPreprocess, InputField, (more) Games: Momento Temporis
"If each mistake being made is a new one, then progress is being made."
"If each mistake being made is a new one, then progress is being made."
Re: Have you coded a block chain for fun?
Blockchain: an immutable data structure secured by cryptographic principles
Cryptocurrency: the thing most of you are talking about
Misconceptions from start to finish. Let's talk about tech, not ideology.
Cryptocurrency: the thing most of you are talking about
Misconceptions from start to finish. Let's talk about tech, not ideology.
Who is online
Users browsing this forum: Ahrefs [Bot], Bing [Bot] and 9 guests