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

draft: support merklized credential #1

Open
wants to merge 15 commits into
base: main
Choose a base branch
from

Conversation

ilya-korotya
Copy link
Collaborator

@ilya-korotya ilya-korotya commented Dec 26, 2024

Copy link

@demonsh demonsh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add description to the VC templates. Move it to separate folder.

  • Instructions how to generate templates and how it works, so developers will understand the algorithm
  • Move Merklization to separate Template.
  • Move ClaimRootBuilder to separate file

include "./helpers/signature.circom";
include "./helpers/extractor.circom";
include "./helpers/nullifier.circom";


template ClaimRootBuilder(nLevels) {
signal input templateRoot;
signal input siblings[10][nLevels];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Create a template param with number of smt changes.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

smt[i].isOld0 <== 0;
smt[i].newKey <== keys[i];
smt[i].newValue <== values[i];
smt[i].fnc <== [0, 1];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function value you pass doesn't look correct here.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I pass the update flag as here in the example: https://github.com/iden3/circomlib/blob/master/test/smtprocessor.js#L73

}
const templateRoot = tree.F.toObject(tree.root);

const constLefasUpdate = [
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@@ -79,6 +79,54 @@ function prepareTestData() {
),
)

const tree = await newMemEmptyTrie();
const leafs = [
"4809579517396073186705705159186899409599314609122482090560534255195823961763", "2038038677412689124034084719683107814279606773706261227437666149072023632255",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please add comments here too? What are the first & second values on each line and how have you calculated them.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

revealState: 0,

revocationNonce: 954548273,
credentialStatusID: "1018201307016207665766251269200564043201648522038849723333336008159229499355",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add comments on how you got these values.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm going to create notion page with instructions how to calculate all key-value pairs.

assert(Number(witness[6]) === 0)
assert(Number(witness[7]) === 0)
await circuit.checkConstraints(witness);
assert(witness[3] === BigInt("4230341195722595158824846810955105073061381863438730322129274755644729517884"));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What are you checking here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

// Pin code
assert(Number(witness[5]) === 110051)

// State
assert(bigIntsToString([witness[4]]) === 'Delhi')
// Data of birth on integer format
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Date, not data.
In integer format, not on.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@@ -98,4 +122,25 @@ template AadhaarQRVerifier(n, k, maxDataLength) {

// Dummy square to prevent signal tampering (in rare cases where non-constrained inputs are ignored)
signal signalHashSquare <== signalHash * signalHash;

// The value was calculated using the go-iden3-core library
var i0 = 11838043422440293315007254764009275008602;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add set of attributes for the library

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

Successfully merging this pull request may close these issues.

3 participants