Skip to content

Instantly share code, notes, and snippets.

View stefandeml's full-sized avatar
⛷️
Winter Season.

Stefan stefandeml

⛷️
Winter Season.
  • Zurich, Switzerland
View GitHub Profile
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
#!/usr/bin/env bash
set -xeuo pipefail
# Cleanup
set +e
umount /mnt/boot
umount /mnt
vgchange -an vgnvme
set -e
# Create partitions
parted --script /dev/nvme0n1 mklabel gpt
parted --script --align optimal /dev/nvme0n1 -- mklabel gpt mkpart 'ESP-partition' fat32 1MB 551MB set 1 esp on mkpart 'LVM-partition' 551MB '100%'
partprobe
udevadm settle --timeout=5 --exit-if-exists=/dev/nvme0n1p1
udevadm settle --timeout=5 --exit-if-exists=/dev/nvme0n1p2
# Cleanup
wipefs -a /dev/nvme0n1p1
wipefs -a /dev/nvme0n1p2
set +e
def main(field a, field b) -> (field):
field result = a + b
return result
import "ecc/babyjubjubParams.code" as context
// Add two points on a twisted Edwards curve
// Curve parameters are defined with the last argument
// https://en.wikipedia.org/wiki/Twisted_Edwards_curve#Addition_on_twisted_Edwards_curves
def main(field[2] pt1, field[2] pt2, field[10] context) -> (field[2]):
field a = context[0]
field d = context[1]
field u1 = pt1[0]
@stefandeml
stefandeml / ZoKrates non-Repudiable Identity-Linked Proofs of Knowledge
Created April 8, 2019 12:46
ZoKrates non-Repudiable Identity-Linked Proofs of Knowledge
import "ecc/babyjubjubParams.code" as context
import "ecc/proofOfOwnership.code" as proofOfOwnership
import "hashes/sha256/512bitPacked.code" as sha256packed
def proofOfKnowledge(private field[4] secret, field[2] hash) -> (field):
// check that the computed hash matches the input
hash == sha256packed(secret)
return 1
def main(field[2] pkA, field[2] pkB, field[2] hash, private field skA, private field[4] secret, private field skB) -> (field):
@stefandeml
stefandeml / ZoKrates Identity-linked Proof of Knowledge
Last active December 18, 2021 11:16
ZoKrates Identity-linked Proof of Knowledge
import "ecc/babyjubjubParams.code" as context
import "ecc/proofOfOwnership.code" as proofOfOwnership
import "hashes/sha256/512bitPacked.code" as sha256packed
def hash(private field[4] secret) -> (field[2]):
return sha256packed(secret)
def main(field[2] pkA, private field[4] secret, private field skA) -> (field[2]):
// load BabyJubJub context
context = context()
// prove ownership of skA
import "ecc/babyjubjubParams.code" as context
import "ecc/proofOfOwnership.code" as proofOfOwnership
import "hashes/sha256/512bitPacked.code" as sha256packed
def proofOfKnowledge(private field i1, private field i2, private field i3, private field i4, field h0, field h1) -> (field):
digest = sha256packed([i1, i2, i3, i4])
digest[0] == h0
digest[1] == h1
return 1
import "ecc/babyjubjubParams.code" as context
import "ecc/proofOfOwnership.code" as proofOfOwnership
import "hashes/sha256/512bitPacked.code" as sha256packed
def proofOfKnowledge(private field i1, private field i2, private field i3, private field i4, field h0, field h1) -> (field):
digest = sha256packed([i1, i2, i3, i4])
digest[0] == h0
digest[1] == h1
return 1
%load_ext autoreload
%autoreload 2
# %%
import hashlib
from zokrates.eddsa import PrivateKey, PublicKey
from zokrates.field import FQ
from zokrates.utils import write_for_zokrates_cli