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

feat!: return Pedersen structure in stdlib #3190

Merged
merged 63 commits into from
Oct 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
63 commits
Select commit Hold shift + click to select a range
bf4c899
return PedersenPoint from perdersen function
guipublic Oct 17, 2023
3f75386
Merge branch 'master' into gd/issue_3161
guipublic Oct 17, 2023
35fe7e7
Merge branch 'master' into gd/issue_3161
guipublic Oct 20, 2023
96404eb
Merge branch 'master' into gd/issue_3161
guipublic Oct 23, 2023
811058d
chore: move empty circuits to `compile_success_empty` (#3247)
TomAFrench Oct 23, 2023
6029029
chore: add constructor formatter (#3243)
Oct 23, 2023
017f7cf
chore(ci): Generate circuit benchmark summaries on PRs (#3250)
TomAFrench Oct 23, 2023
8af441e
feat: Cache debug artifacts (#3133)
TomAFrench Oct 23, 2023
6ae87a7
chore: enhance code formatting for If expressions (#3246)
Oct 23, 2023
a055e0a
feat(stdlib): optimize constraint counts in sha256/sha512 (#3253)
TomAFrench Oct 23, 2023
f1f40ef
fix: Impl methods are no longer placed in contracts (#3255)
jfecher Oct 23, 2023
3d56168
chore(docs): document info codelens (#3252)
TomAFrench Oct 23, 2023
e960085
fix: Show println output before an error occurs in `nargo execute` (#…
jfecher Oct 23, 2023
e9956cf
chore: Update ACIR artifacts (#3263)
kevaundray Oct 24, 2023
0d0be23
fix: recompile artefacts from a different noir version (#3248)
guipublic Oct 24, 2023
112a33f
feat(debugger): Print limited source code context (#3217)
mverzilli Oct 24, 2023
36508c2
chore(docs): Document `nargo fmt` (#3262)
Savio-Sou Oct 24, 2023
5874a87
chore(docs): Rearrange NoirJS section (#3260)
Savio-Sou Oct 24, 2023
0a15936
feat: noir-wasm takes dependency graph (#3213)
alexghr Oct 24, 2023
8b66686
feat!: Switch to new pedersen implementation (#3151)
kevaundray Oct 24, 2023
7d73590
feat: replace boolean range constraints with arithmetic opcodes (#3234)
TomAFrench Oct 24, 2023
4b2e8bf
feat: implement euclidean division and signed division in terms of `A…
TomAFrench Oct 24, 2023
2db2180
chore: fix empty constructor formatting (#3265)
Oct 24, 2023
efa19fa
feat: add crate for pub modifier (#3271)
guipublic Oct 24, 2023
0db5f40
chore: method specialization (#3268)
signorecello Oct 24, 2023
4ae19a3
fix: Fix lexer error formatting (#3274)
jfecher Oct 24, 2023
506f7dc
chore: standardize workflow triggers (#3277)
TomAFrench Oct 24, 2023
e796cd3
chore: add constrain formatter (#3272)
Oct 24, 2023
c7456ba
fix: Add size checks to integer literals (#3236)
jfecher Oct 24, 2023
c478471
feat: implement `bound_constraint_with_offset` in terms of `AcirVar`s…
TomAFrench Oct 24, 2023
e6ca7b5
chore: adding fix to master branch (#3279)
signorecello Oct 24, 2023
ec332dc
feat!: expose pedersen hash in acir and bb solver (#3269)
sirasistant Oct 25, 2023
70ed98c
chore: turn off `aztec` flag by default (#3280)
TomAFrench Oct 25, 2023
8969efd
chore: Release Noir(0.18.0) (#3242)
kevaundray Oct 25, 2023
2ab00da
chore: pinning NoirJS guide versions to 0.17.0 and adding note on noi…
signorecello Oct 25, 2023
fc67016
feat: Extract Brillig VM to allow step debugging (#3259)
ggiraldez Oct 25, 2023
15d03d1
feat: perform compile-time euclidean division on constants (#3231)
TomAFrench Oct 25, 2023
0a4e206
chore: update artefacts (#3287)
kevaundray Oct 25, 2023
5639698
chore: remove `default` empty features array (#3285)
alexghr Oct 25, 2023
2c1f786
chore(docs): Cut v0.17.0 docs (#3290)
Savio-Sou Oct 25, 2023
02721d6
chore: update relative paths for docs imports (#3291)
critesjosh Oct 25, 2023
ee39d36
chore(docs): Recommend `yarn` instead of for cutting doc versions (#3…
Savio-Sou Oct 25, 2023
3214d25
feat: Allow a trait to be implemented multiple times for the same str…
jfecher Oct 25, 2023
cc7bf2a
chore: format submodule/contract (#3286)
Oct 25, 2023
e4b08ec
chore(github): Update PR template per new documentation workflow (#3241)
Savio-Sou Oct 25, 2023
3d8b802
feat: handle warnings in evaluator (#3205)
guipublic Oct 26, 2023
e89fa13
feat: `compute_note_hash_and_nullifier` check (#3216)
benesjan Oct 26, 2023
9771b8d
feat: Make generic impls callable (#3297)
jfecher Oct 26, 2023
3d70ee8
chore: create publish-docs.yml (#3298)
signorecello Oct 26, 2023
2e65c12
chore(docs): Supplement descriptions for defaulting loop indices to b…
Savio-Sou Oct 26, 2023
e25a839
chore: bump bb version to 0.12.0 (#3304)
TomAFrench Oct 26, 2023
decb8a5
chore: upload acir artifacts as a github artifact (#3288)
TomAFrench Oct 26, 2023
aadcf56
feat: add exports of JS black box solvers to noirJS (#3295)
TomAFrench Oct 26, 2023
fb4c8b7
chore: add bn254 attribute when needed in the stdlib (#3208)
guipublic Oct 26, 2023
7d79006
chore: recrawl docs on merge (#3306)
signorecello Oct 26, 2023
c15a68b
Merge branch 'master' into gd/issue_3161
guipublic Oct 27, 2023
961f894
fix the build and update the doc
guipublic Oct 27, 2023
2894b84
Merge branch 'master' into gd/issue_3161
guipublic Oct 27, 2023
0413da9
Merge branch 'master' into gd/issue_3161
signorecello Oct 28, 2023
7a2f47b
Merge branch 'master' into gd/issue_3161
guipublic Oct 31, 2023
46b49e0
fix merge issue
guipublic Oct 31, 2023
61d96ad
Merge branch 'master' into gd/issue_3161
guipublic Oct 31, 2023
3447e04
fix merge issue(2)
guipublic Oct 31, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions noir_stdlib/src/hash.nr
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,25 @@ pub fn sha256<N>(_input : [u8; N]) -> [u8; 32] {}
#[foreign(blake2s)]
pub fn blake2s<N>(_input : [u8; N]) -> [u8; 32] {}

pub fn pedersen_commitment<N>(input : [Field; N]) -> [Field; 2] {
struct PedersenPoint {
x : Field,
y : Field,
}

pub fn pedersen_commitment<N>(input : [Field; N]) -> PedersenPoint {
pedersen_commitment_with_separator(input, 0)
}

#[foreign(pedersen)]
pub fn pedersen_commitment_with_separator<N>(_input : [Field; N], _separator : u32) -> [Field; 2] {}
pub fn __pedersen_commitment_with_separator<N>(_input : [Field; N], _separator : u32) -> [Field; 2] {}

pub fn pedersen_commitment_with_separator<N>(input : [Field; N], separator : u32) -> PedersenPoint {
let values = __pedersen_commitment_with_separator(input, separator);
PedersenPoint {
x: values[0],
y: values[1],
}
}

pub fn pedersen_hash<N>(input : [Field; N]) -> Field {
pedersen_hash_with_separator(input, 0)
Expand Down
2 changes: 1 addition & 1 deletion noir_stdlib/src/lib.nr
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,4 @@ pub fn wrapping_mul<T>(x : T, y: T) -> T {
/// Shift-left x by y bits
/// If the result overflow the bitsize; it does not fail and returns 0 instead
#[builtin(wrapping_shift_left)]
pub fn wrapping_shift_left<T>(x : T, y: T) -> T {}
pub fn wrapping_shift_left<T>(_x : T, _y: T) -> T {}
1 change: 1 addition & 0 deletions tooling/debugger/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use acvm::BlackBoxFunctionSolver;
use acvm::{acir::circuit::Circuit, acir::native_types::WitnessMap};

use nargo::artifacts::debug::DebugArtifact;

use nargo::NargoError;

pub fn debug_circuit<B: BlackBoxFunctionSolver>(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,17 +39,20 @@ impl F for Bar {
fn f3(self) -> Field { 30 }
}


// Impls on mutable references are temporarily disabled
// impl F for &mut Bar {
// fn f1(self) -> Field { 101 }
// fn f5(self) -> Field { 505 }
// }


fn main(x: Field) {
let first = Foo::method2(x);
assert(first == 3 * x);

let bar = Bar{};

assert(bar.f1() == 10, "1");
assert(bar.f2() == 2, "2");
assert(bar.f3() == 30, "3");
Expand All @@ -71,3 +74,4 @@ fn main(x: Field) {
assert(bar_mut.f4() == 4, "14");
assert(bar_mut.f5() == 50, "15");
}

Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,15 @@ use dep::std;

unconstrained fn main(x: Field, y: Field, salt: Field, out_x: Field, out_y: Field, out_hash: Field) {
let res = std::hash::pedersen_commitment_with_separator([x, y], 0);
assert(res[0] == out_x);
assert(res[1] == out_y);
assert(res.x == out_x);
assert(res.y == out_y);


let res_hash = std::hash::pedersen_hash_with_separator([x, y], 0);
assert_eq(res_hash, out_hash);

assert(res_hash != res[0]);
assert(res_hash != res.x);


let raw_data = [x, y];
let mut state = 0;
Expand All @@ -16,6 +19,6 @@ unconstrained fn main(x: Field, y: Field, salt: Field, out_x: Field, out_y: Fiel
}
state += salt;
let hash = std::hash::pedersen_commitment_with_separator([state], 0);
assert(std::hash::pedersen_commitment_with_separator([43], 0)[0] == hash[0]);
assert(std::hash::pedersen_commitment_with_separator([43], 0).x == hash.x);
}

Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@ use dep::std;

fn main(x: Field, y: Field, salt: Field, out_x: Field, out_y: Field, out_hash: Field) {
let res = std::hash::pedersen_commitment([x, y]);
assert(res[0] == out_x);
assert(res[1] == out_y);
assert(res.x == out_x);
assert(res.y == out_y);

let res_hash = std::hash::pedersen_hash_with_separator([x, y], 0);
assert_eq(res_hash, out_hash);

assert(res_hash != res[0]);
assert(res_hash != res.x);


let raw_data = [x, y];
let mut state = 0;
Expand All @@ -16,6 +18,6 @@ fn main(x: Field, y: Field, salt: Field, out_x: Field, out_y: Field, out_hash: F
}
state += salt;
let hash = std::hash::pedersen_commitment([state]);
assert(std::hash::pedersen_commitment([43])[0] == hash[0]);
assert(std::hash::pedersen_commitment([43]).x == hash.x);
}

Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ fn main(
let note_commitment = std::hash::pedersen_commitment([pubkey_x, pubkey_y]);

// Compute input note nullifier
let nullifier = std::hash::pedersen_commitment([note_commitment[0], index, priv_key]);
let nullifier = std::hash::pedersen_commitment([note_commitment.x, index, priv_key]);

// Compute output note nullifier
let receiver_note_commitment = std::hash::pedersen_commitment([to_pubkey_x, to_pubkey_y]);

// Check that the input note nullifier is in the root
assert(note_root == std::merkle::compute_merkle_root(note_commitment[0], index, note_hash_path));
assert(note_root == std::merkle::compute_merkle_root(note_commitment.x, index, note_hash_path));

[nullifier[0], receiver_note_commitment[0]]
[nullifier.x, receiver_note_commitment.x]
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ fn test_should_fail_without_match() {

#[test(should_fail_with = "Not equal")]
fn test_should_fail_with_runtime_match() {
assert_eq(dep::std::hash::pedersen_commitment([27])[0], 0, "Not equal");
assert_eq(dep::std::hash::pedersen_commitment([27]).x, 0, "Not equal");
}

#[test(should_fail)]
fn test_should_fail_without_runtime_match() {
assert_eq(dep::std::hash::pedersen_commitment([27])[0], 0);
assert_eq(dep::std::hash::pedersen_commitment([27]).x, 0);
}
Loading