Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sample code in README #4

Open
oleganza opened this issue Nov 24, 2021 · 0 comments
Open

Sample code in README #4

oleganza opened this issue Nov 24, 2021 · 0 comments

Comments

@oleganza
Copy link

oleganza commented Nov 24, 2021

We need to add a couple samples to help people see how Merlin is used. I just had a conversation with David Vorick who said those examples really help make sense of Merlin.

Example 1: hashing structured data

How HMAC(key, data) would look like on a structured data:

t = Transcript::new(b"Example domain");
t.append_bytes(b"key", b"secretpassword");
t.append_bytes(b"name", b"Merlin");
t.append_bytes(b"job", b"Magic");
hash = t.challenge_bytes(32);

Example 2: use in a ZKP protocol

t = Transcript::new(b"My protocol");
...
t.append_bytes(b"message", ...);
...
t.append_bytes(b"domain-separator", "schnorr-v1");
t.append_bytes(b"X", pubkey.as_point());
t.append_point(b"R", &self.R);
challenge = t.challenge_scalar(b"c");
...

Example 3: generating randomness with TranscriptRNG

...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant