Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
4 changes: 4 additions & 0 deletions scripts/ci-compile-circuits.sh
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ CIRCUITS=(
"bind_evm"
)

# Format generated files
echo "Formatting generated files"
nargo fmt

for circuit in "${CIRCUITS[@]}"; do
nargo compile --force --package "$circuit"
done
Expand Down
10 changes: 7 additions & 3 deletions src/noir/bin/compare/birthdate/evm/src/main.nr
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
use commitment::nullify;
use compare_date_lib::{calculate_param_commitment_sha2, compare_date, get_birthdate};
use compare_date_lib::{calculate_param_commitment_sha2, compare_date};
use utils::dg1::DG1;
use utils::PROOF_TYPE_BIRTHDATE;
use utils::types::DG1Data;

fn main(
comm_in: pub Field,
salt: Field,
private_nullifier: Field,
dg1: [u8; 95],
dg1: DG1Data,
// @committed
// The current date is public (via the parameter commitment) so verifiers can check the date
// provided to the proof is correct
Expand All @@ -24,7 +26,9 @@ fn main(
service_scope: pub Field,
service_subscope: pub Field,
) -> pub (Field, Field) {
let birthdate = get_birthdate(dg1, current_date.as_bytes());
let dg1_data = DG1::new(dg1);
let birthdate = dg1_data.get_birthdate(current_date.as_bytes());

// Verify the birthdate of the ID holder
compare_date(birthdate, min_date.as_bytes(), max_date.as_bytes());
let nullifier = nullify(
Expand Down
9 changes: 6 additions & 3 deletions src/noir/bin/compare/birthdate/standard/src/main.nr
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
use commitment::nullify;
use compare_date_lib::{calculate_param_commitment, compare_date, get_birthdate};
use compare_date_lib::{calculate_param_commitment, compare_date};
use utils::dg1::DG1;
use utils::PROOF_TYPE_BIRTHDATE;
use utils::types::DG1Data;

fn main(
comm_in: pub Field,
salt: Field,
private_nullifier: Field,
dg1: [u8; 95],
dg1: DG1Data,
// @committed
// The current date is public (via the parameter commitment) so verifiers can check the date
// provided to the proof is correct
Expand All @@ -24,7 +26,8 @@ fn main(
service_scope: pub Field,
service_subscope: pub Field,
) -> pub (Field, Field) {
let birthdate = get_birthdate(dg1, current_date.as_bytes());
let dg1_data = DG1::new(dg1);
let birthdate = dg1_data.get_birthdate(current_date.as_bytes());
// Verify the birthdate of the ID holder
compare_date(birthdate, min_date.as_bytes(), max_date.as_bytes());
let nullifier = nullify(
Expand Down
1 change: 1 addition & 0 deletions src/noir/bin/compare/citizenship/Nargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ compiler_version = ">=1.0.0"
[dependencies]
compare_citizenship = { path = "../../../lib/compare/citizenship" }
commitment = { path = "../../../lib/commitment/scoped-nullifier" }
utils = { path = "../../../lib/utils" }
8 changes: 6 additions & 2 deletions src/noir/bin/compare/citizenship/src/main.nr
Original file line number Diff line number Diff line change
@@ -1,19 +1,23 @@
use commitment::nullify;
use compare_citizenship::compare_citizenship;
use utils::dg1::DG1;
use utils::types::DG1Data;

fn main(
comm_in: pub Field,
salt: Field,
private_nullifier: Field,
dg1: [u8; 95],
dg1: DG1Data,
// The country is public so verifiers can check
// the country provided to the proof is correct
country: pub str<3>,
service_scope: pub Field,
service_subscope: pub Field,
) -> pub Field {
// Verify the country of the passport holder
compare_citizenship(dg1, country.as_bytes());
let dg1_data = DG1::new(dg1);
compare_citizenship(dg1_data, country.as_bytes());

let nullifier = nullify(
comm_in,
salt,
Expand Down
9 changes: 6 additions & 3 deletions src/noir/bin/compare/expiry/evm/src/main.nr
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
use commitment::nullify;
use compare_date_lib::{calculate_param_commitment_sha2, compare_date, get_expiry_date};
use compare_date_lib::{calculate_param_commitment_sha2, compare_date};
use utils::dg1::DG1;
use utils::PROOF_TYPE_EXPIRY_DATE;
use utils::types::DG1Data;

fn main(
comm_in: pub Field,
salt: Field,
private_nullifier: Field,
dg1: [u8; 95],
dg1: DG1Data,
// @committed
// The current date is public so verifiers can check the date
// provided to the proof is correct
Expand All @@ -24,7 +26,8 @@ fn main(
service_scope: pub Field,
service_subscope: pub Field,
) -> pub (Field, Field) {
let expiry_date = get_expiry_date(dg1, current_date.as_bytes());
let dg1_data = DG1::new(dg1);
let expiry_date = dg1_data.get_expiry_date(current_date.as_bytes());
// Verify the expiry date of the ID holder
compare_date(expiry_date, min_date.as_bytes(), max_date.as_bytes());
// Use SHA2-256 to calculate the parameter commitment so the parameter commitment can be
Expand Down
10 changes: 7 additions & 3 deletions src/noir/bin/compare/expiry/standard/src/main.nr
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
use commitment::nullify;
use compare_date_lib::{calculate_param_commitment, compare_date, get_expiry_date};
use compare_date_lib::{calculate_param_commitment, compare_date};
use utils::dg1::DG1;
use utils::PROOF_TYPE_EXPIRY_DATE;
use utils::types::DG1Data;

fn main(
comm_in: pub Field,
salt: Field,
private_nullifier: Field,
dg1: [u8; 95],
dg1: DG1Data,
// @committed
// The current date is public so verifiers can check the date
// provided to the proof is correct
Expand All @@ -24,7 +26,9 @@ fn main(
service_scope: pub Field,
service_subscope: pub Field,
) -> pub (Field, Field) {
let expiry_date = get_expiry_date(dg1, current_date.as_bytes());
let dg1_data = DG1::new(dg1);
let expiry_date = dg1_data.get_expiry_date(current_date.as_bytes());

// Verify the expiry date of the ID holder
compare_date(expiry_date, min_date.as_bytes(), max_date.as_bytes());
// Use Poseidon2 to calculate the parameter commitment so the prover has less work to do
Expand Down
7 changes: 5 additions & 2 deletions src/noir/bin/data-check/expiry/src/main.nr
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
use data_check_expiry::check_expiry;
use utils::dg1::DG1;
use utils::types::DG1Data;

fn main(dg1: [u8; 95], current_date: pub str<8>) {
fn main(dg1: DG1Data, current_date: pub str<8>) {
let dg1_data = DG1::new(dg1);
// Check the ID is not expired first
check_expiry(dg1, current_date.as_bytes());
check_expiry(dg1_data, current_date.as_bytes());
}
1 change: 1 addition & 0 deletions src/noir/bin/data-check/integrity/sha1/Nargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ compiler_version = ">=1.0.0"
data_check_integrity = { path = "../../../../lib/data-check/integrity" }
data_check_expiry = { path = "../../../../lib/data-check/expiry" }
commitment = { path = "../../../../lib/commitment/integrity-to-disclosure" }
utils = { path = "../../../../lib/utils" }
9 changes: 6 additions & 3 deletions src/noir/bin/data-check/integrity/sha1/src/main.nr
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,28 @@
use commitment::commit_to_disclosure;
use data_check_expiry::check_expiry;
use data_check_integrity::check_integrity_of_data_sha1;
use utils::dg1::DG1;
use utils::types::DG1Data;

fn main(
current_date: pub str<8>,
comm_in: pub Field,
salt_in: Field,
salt_out: Field,
dg1: [u8; 95],
dg1: DG1Data,
signed_attributes: [u8; 200],
signed_attributes_size: u32,
e_content: [u8; 700],
e_content_size: u32,
dg1_offset_in_e_content: u32,
private_nullifier: Field,
) -> pub Field {
let dg1_data = DG1::new(dg1);
// Check the ID is not expired first
check_expiry(dg1, current_date.as_bytes());
check_expiry(dg1_data, current_date.as_bytes());
// Check the integrity of the data
check_integrity_of_data_sha1(
dg1,
dg1_data,
signed_attributes,
signed_attributes_size,
e_content,
Expand Down
1 change: 1 addition & 0 deletions src/noir/bin/data-check/integrity/sha256/Nargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ compiler_version = ">=1.0.0"
data_check_integrity = { path = "../../../../lib/data-check/integrity" }
data_check_expiry = { path = "../../../../lib/data-check/expiry" }
commitment = { path = "../../../../lib/commitment/integrity-to-disclosure" }
utils = { path = "../../../../lib/utils" }
9 changes: 6 additions & 3 deletions src/noir/bin/data-check/integrity/sha256/src/main.nr
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,28 @@
use commitment::commit_to_disclosure;
use data_check_expiry::check_expiry;
use data_check_integrity::check_integrity_of_data_sha256;
use utils::dg1::DG1;
use utils::types::DG1Data;

fn main(
current_date: pub str<8>,
comm_in: pub Field,
salt_in: Field,
salt_out: Field,
dg1: [u8; 95],
dg1: DG1Data,
signed_attributes: [u8; 200],
signed_attributes_size: u32,
e_content: [u8; 700],
e_content_size: u32,
dg1_offset_in_e_content: u32,
private_nullifier: Field,
) -> pub Field {
let dg1_data = DG1::new(dg1);
// Check the ID is not expired first
check_expiry(dg1, current_date.as_bytes());
check_expiry(dg1_data, current_date.as_bytes());
// Check the integrity of the data
check_integrity_of_data_sha256(
dg1,
dg1_data,
signed_attributes,
signed_attributes_size,
e_content,
Expand Down
1 change: 1 addition & 0 deletions src/noir/bin/data-check/integrity/sha384/Nargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ compiler_version = ">=1.0.0"
data_check_integrity = { path = "../../../../lib/data-check/integrity" }
data_check_expiry = { path = "../../../../lib/data-check/expiry" }
commitment = { path = "../../../../lib/commitment/integrity-to-disclosure" }
utils = { path = "../../../../lib/utils" }
9 changes: 6 additions & 3 deletions src/noir/bin/data-check/integrity/sha384/src/main.nr
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,28 @@
use commitment::commit_to_disclosure;
use data_check_expiry::check_expiry;
use data_check_integrity::check_integrity_of_data_sha384;
use utils::dg1::DG1;
use utils::types::DG1Data;

fn main(
current_date: pub str<8>,
comm_in: pub Field,
salt_in: Field,
salt_out: Field,
dg1: [u8; 95],
dg1: DG1Data,
signed_attributes: [u8; 200],
signed_attributes_size: u32,
e_content: [u8; 700],
e_content_size: u32,
dg1_offset_in_e_content: u32,
private_nullifier: Field,
) -> pub Field {
let dg1_data = DG1::new(dg1);
// Check the ID is not expired first
check_expiry(dg1, current_date.as_bytes());
check_expiry(dg1_data, current_date.as_bytes());
// Check the integrity of the data
check_integrity_of_data_sha384(
dg1,
dg1_data,
signed_attributes,
signed_attributes_size,
e_content,
Expand Down
1 change: 1 addition & 0 deletions src/noir/bin/data-check/integrity/sha512/Nargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ compiler_version = ">=1.0.0"
data_check_integrity = { path = "../../../../lib/data-check/integrity" }
data_check_expiry = { path = "../../../../lib/data-check/expiry" }
commitment = { path = "../../../../lib/commitment/integrity-to-disclosure" }
utils = { path = "../../../../lib/utils" }
10 changes: 7 additions & 3 deletions src/noir/bin/data-check/integrity/sha512/src/main.nr
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@
use commitment::commit_to_disclosure;
use data_check_expiry::check_expiry;
use data_check_integrity::check_integrity_of_data_sha512;
use utils::dg1::DG1;
use utils::types::DG1Data;

fn main(
current_date: pub str<8>,
comm_in: pub Field,
salt_in: Field,
salt_out: Field,
dg1: [u8; 95],
dg1: DG1Data,
signed_attributes: [u8; 200],
signed_attributes_size: u32,
e_content: [u8; 700],
Expand All @@ -17,10 +19,12 @@ fn main(
private_nullifier: Field,
) -> pub Field {
// Check the ID is not expired first
check_expiry(dg1, current_date.as_bytes());
let dg1_data = DG1::new(dg1);

check_expiry(dg1_data, current_date.as_bytes());
// Check the integrity of the data
check_integrity_of_data_sha512(
dg1,
dg1_data,
signed_attributes,
signed_attributes_size,
e_content,
Expand Down
3 changes: 2 additions & 1 deletion src/noir/bin/disclose/bytes/evm/Nargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ compiler_version = ">=1.0.0"

[dependencies]
disclose = { path = "../../../../lib/disclose" }
commitment = { path = "../../../../lib/commitment/scoped-nullifier" }
commitment = { path = "../../../../lib/commitment/scoped-nullifier" }
utils = { path = "../../../../lib/utils" }
7 changes: 5 additions & 2 deletions src/noir/bin/disclose/bytes/evm/src/main.nr
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
use commitment::nullify;
use disclose::{calculate_param_commitment_sha2, get_disclosed_bytes};
use utils::dg1::DG1;
use utils::types::DG1Data;

fn main(
comm_in: pub Field,
salt: Field,
private_nullifier: Field,
dg1: [u8; 95],
dg1: DG1Data,
// @committed
// The disclose mask is public (via the parameter commitment) so verifiers can check the mask
disclose_mask: [u8; 90],
Expand All @@ -14,7 +16,8 @@ fn main(
) -> pub (Field, Field) {
// @committed
// The disclose bytes are public (via the parameter commitment) so verifiers can check the bytes
let disclosed_bytes = get_disclosed_bytes(dg1, disclose_mask);
let dg1_data = DG1::new(dg1);
let disclosed_bytes = get_disclosed_bytes(dg1_data, disclose_mask);
let scoped_nullifier = nullify(
comm_in,
salt,
Expand Down
1 change: 1 addition & 0 deletions src/noir/bin/disclose/bytes/standard/Nargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ compiler_version = ">=1.0.0"
[dependencies]
disclose = { path = "../../../../lib/disclose" }
commitment = { path = "../../../../lib/commitment/scoped-nullifier" }
utils = { path = "../../../../lib/utils" }
7 changes: 5 additions & 2 deletions src/noir/bin/disclose/bytes/standard/src/main.nr
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
use commitment::nullify;
use disclose::{calculate_param_commitment, get_disclosed_bytes};
use utils::dg1::DG1;
use utils::types::DG1Data;

fn main(
comm_in: pub Field,
salt: Field,
private_nullifier: Field,
dg1: [u8; 95],
dg1: DG1Data,
// @committed
// The disclose mask is public (via the parameter commitment) so verifiers can check the mask
disclose_mask: [u8; 90],
Expand All @@ -14,7 +16,8 @@ fn main(
) -> pub (Field, Field) {
// @committed
// The disclose bytes are public (via the parameter commitment) so verifiers can check the bytes
let disclosed_bytes = get_disclosed_bytes(dg1, disclose_mask);
let dg1_data = DG1::new(dg1);
let disclosed_bytes = get_disclosed_bytes(dg1_data, disclose_mask);
let scoped_nullifier = nullify(
comm_in,
salt,
Expand Down
Loading