Skip to content

Instantly share code, notes, and snippets.

@syuhei176
Last active September 25, 2018 12:28
Show Gist options
  • Save syuhei176/11008cdf038cc66bf7ff8d01c50612be to your computer and use it in GitHub Desktop.
Save syuhei176/11008cdf038cc66bf7ff8d01c50612be to your computer and use it in GitHub Desktop.
beginner zk
function add(a, b, c) {
return (hash(hash(a) + hash(b)) == hash(c));
}
function sub(a, b, c) {
return (hash(hash(a) - hash(b)) == hash(c));
}
function hash(a) {
if(a < 0) {
return hash(a + 23)
} else {
return a % 23;
}
}
// true
// 1 + 2 = 3
console.log(add(1, 2, 3));
// 100 + 200 = 300
console.log(add(100, 200, 300));
console.log(add(120, 150, 270));
console.log(add(51, 52, 103));
console.log(sub(52, 51, 1));
console.log(sub(123, 87, 36));
// false
console.log(add(2, 50, 51));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment