Skip to content

Instantly share code, notes, and snippets.

@rumkin
Last active May 25, 2020 17:31
Show Gist options
  • Save rumkin/d82dad4286ff909dbe8b2996bc654533 to your computer and use it in GitHub Desktop.
Save rumkin/d82dad4286ff909dbe8b2996bc654533 to your computer and use it in GitHub Desktop.
Proofs for ideas

Ephemeral Patents

  • Hash: e132645f3c2072e44769b025b338b2e649e743140ad14e7fd846cf005c5f672f Date: 25-02-2020
  • Hash: 4d4814b2978635d27efb0b0eefa248f6b5514e13d26d78671c8ec9bddf3fc1cf Date: 25-02-2020
import {createHash, randomBytes} from 'crypto'
function sha256(...args) {
const hash = createHash('sha256')
for (const value of args) {
hash.update(value)
}
return hash.digest()
}
export function createProof(message) {
const entropy = randomBytes(32)
const hash = sha256(entropy, message)
return {
hash: hash.toString('hex'),
entropy: entropy.toString('hex'),
}
}
export function verifyProof({
message,
hash,
entropy,
}) {
const checksum = sha256(Buffer.from(entropy, 'hex'), message)
return checksum.compare(Buffer.from(hash, 'hex')) === 0
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment