Merge pull request #2019 from AleoHQ/feat/ped-commit

Implement ped64 and ped128 commit operators
This commit is contained in:
Collin Chin 2022-08-15 22:27:03 -07:00 committed by GitHub
commit 1370c4a91c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 539 additions and 215 deletions

570
Cargo.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -62,11 +62,11 @@ version = "1.5.3"
[dependencies.aleo]
git = "https://github.com/AleoHQ/aleo.git"
rev = "4064f1c"
rev = "d781ee4"
[dependencies.snarkvm]
git = "https://github.com/AleoHQ/snarkVM.git"
rev = "22f3aa8"
rev = "45a6f01"
features = ["aleo-cli", "circuit", "console", "parallel"]
[dependencies.backtrace]

View File

@ -47,7 +47,7 @@ version = "1.4.0"
[dev-dependencies.snarkvm]
git = "https://github.com/AleoHQ/snarkVM.git"
rev = "22f3aa8"
rev = "45a6f01"
features = ["aleo-cli", "circuit", "console", "parallel"]
[dev-dependencies.serde]

View File

@ -37,9 +37,9 @@ pub enum CoreInstruction {
BHP1024Commit,
BHP1024Hash,
// Pedersen64Commit,
Pedersen64Commit,
Pedersen64Hash,
// Pedersen128Commit,
Pedersen128Commit,
Pedersen128Hash,
Poseidon2Hash,
@ -60,9 +60,9 @@ impl CoreInstruction {
(sym::BHP1024, sym::commit) => Self::BHP1024Commit,
(sym::BHP1024, sym::hash) => Self::BHP1024Hash,
// (sym::Pedersen64, sym::commit) => Self::Pedersen64Commit,
(sym::Pedersen64, sym::commit) => Self::Pedersen64Commit,
(sym::Pedersen64, sym::hash) => Self::Pedersen64Hash,
// (sym::Pedersen128, sym::commit) => Self::Pedersen128Commit,
(sym::Pedersen128, sym::commit) => Self::Pedersen128Commit,
(sym::Pedersen128, sym::hash) => Self::Pedersen128Hash,
(sym::Poseidon2, sym::hash) => Self::Poseidon2Hash,
@ -84,9 +84,9 @@ impl CoreInstruction {
Self::BHP1024Commit => BHP1024Commit::NUM_ARGS,
Self::BHP1024Hash => BHP1024Hash::NUM_ARGS,
// Self::Pedersen64Commit => Pedersen64Commit::NUM_ARGS,
Self::Pedersen64Commit => Pedersen64Commit::NUM_ARGS,
Self::Pedersen64Hash => Pedersen64Hash::NUM_ARGS,
// Self::Pedersen128Commit => Pedersen128Commit::NUM_ARGS,
Self::Pedersen128Commit => Pedersen128Commit::NUM_ARGS,
Self::Pedersen128Hash => Pedersen128Hash::NUM_ARGS,
Self::Poseidon2Hash => Poseidon2Hash::NUM_ARGS,
@ -107,9 +107,9 @@ impl CoreInstruction {
Self::BHP1024Commit => BHP1024Commit::first_arg_types(),
Self::BHP1024Hash => BHP1024Hash::first_arg_types(),
// Self::Pedersen64Commit => Pedersen64Commit::first_arg_types(),
Self::Pedersen64Commit => Pedersen64Commit::first_arg_types(),
Self::Pedersen64Hash => Pedersen64Hash::first_arg_types(),
// Self::Pedersen128Commit => Pedersen128Commit::first_arg_types(),
Self::Pedersen128Commit => Pedersen128Commit::first_arg_types(),
Self::Pedersen128Hash => Pedersen128Hash::first_arg_types(),
Self::Poseidon2Hash => Poseidon2Hash::first_arg_types(),
@ -130,9 +130,9 @@ impl CoreInstruction {
Self::BHP1024Commit => BHP1024Commit::second_arg_types(),
Self::BHP1024Hash => BHP1024Hash::second_arg_types(),
// Self::Pedersen64Commit => Pedersen64Commit::second_arg_types(),
Self::Pedersen64Commit => Pedersen64Commit::second_arg_types(),
Self::Pedersen64Hash => Pedersen64Hash::second_arg_types(),
// Self::Pedersen128Commit => Pedersen128Commit::second_arg_types(),
Self::Pedersen128Commit => Pedersen128Commit::second_arg_types(),
Self::Pedersen128Hash => Pedersen128Hash::second_arg_types(),
Self::Poseidon2Hash => Poseidon2Hash::second_arg_types(),
@ -153,9 +153,9 @@ impl CoreInstruction {
Self::BHP1024Commit => BHP1024Commit::return_type(),
Self::BHP1024Hash => BHP1024Hash::return_type(),
// Self::Pedersen64Commit => Pedersen64Commit::return_type(),
Self::Pedersen64Commit => Pedersen64Commit::return_type(),
Self::Pedersen64Hash => Pedersen64Hash::return_type(),
// Self::Pedersen128Commit => Pedersen128Commit::return_type(),
Self::Pedersen128Commit => Pedersen128Commit::return_type(),
Self::Pedersen128Hash => Pedersen128Hash::return_type(),
Self::Poseidon2Hash => Poseidon2Hash::return_type(),

View File

@ -31,23 +31,23 @@ impl CoreFunction for Pedersen64Hash {
}
}
// pub struct Pedersen64Commit;
//
// impl CoreFunction for Pedersen64Commit {
// const NUM_ARGS: usize = 2;
//
// fn first_arg_types() -> &'static [Type] {
// &BOOL_INT64_STRING_TYPES
// }
//
// fn second_arg_types() -> &'static [Type] {
// &[Type::Scalar]
// }
//
// fn return_type() -> Type {
// Type::Field
// }
// }
pub struct Pedersen64Commit;
impl CoreFunction for Pedersen64Commit {
const NUM_ARGS: usize = 2;
fn first_arg_types() -> &'static [Type] {
&BOOL_INT64_STRING_TYPES
}
fn second_arg_types() -> &'static [Type] {
&[Type::Scalar]
}
fn return_type() -> Type {
Type::Group
}
}
pub struct Pedersen128Hash;
@ -63,20 +63,20 @@ impl CoreFunction for Pedersen128Hash {
}
}
// pub struct Pedersen128Commit;
//
// impl CoreFunction for Pedersen128Commit {
// const NUM_ARGS: usize = 2;
//
// fn first_arg_types() -> &'static [Type] {
// &BOOL_INT_STRING_TYPES
// }
//
// fn second_arg_types() -> &'static [Type] {
// &[Type::Scalar]
// }
//
// fn return_type() -> Type {
// Type::Field
// }
// }
pub struct Pedersen128Commit;
impl CoreFunction for Pedersen128Commit {
const NUM_ARGS: usize = 2;
fn first_arg_types() -> &'static [Type] {
&BOOL_INT_STRING_TYPES
}
fn second_arg_types() -> &'static [Type] {
&[Type::Scalar]
}
fn return_type() -> Type {
Type::Group
}
}

View File

@ -0,0 +1,34 @@
/*
namespace: Compile
expectation: Pass
input_file: inputs/int64.in
*/
@program
function main(
i8_value: i8,
i16_value: i16,
i32_value: i32,
i64_value: i64,
u8_value: u8,
u16_value: u16,
u32_value: u32,
u64_value: u64,
) -> group {
let bool_value: bool = true;
// let string_value: string = "helloworld";
// Pedersen64 hash tests
let a: group = Pedersen128::commit(bool_value, 1scalar);
let b: group = Pedersen128::commit(i8_value, 1scalar);
let c: group = Pedersen128::commit(i16_value, 1scalar);
let d: group = Pedersen128::commit(i32_value, 1scalar);
let e: group = Pedersen128::commit(i64_value, 1scalar);
let f: group = Pedersen128::commit(u8_value, 1scalar);
let g: group = Pedersen128::commit(u16_value, 1scalar);
let h: group = Pedersen128::commit(u32_value, 1scalar);
let i: group = Pedersen128::commit(u64_value, 1scalar);
// let j11: group = Pedersen128::commit(string_value, 1scalar);
return a + i;
}

View File

@ -0,0 +1,34 @@
/*
namespace: Compile
expectation: Pass
input_file: inputs/int64.in
*/
@program
function main(
i8_value: i8,
i16_value: i16,
i32_value: i32,
i64_value: i64,
u8_value: u8,
u16_value: u16,
u32_value: u32,
u64_value: u64,
) -> group {
let bool_value: bool = true;
// let string_value: string = "helloworld";
// Pedersen64 hash tests
let a: group = Pedersen64::commit(bool_value, 1scalar);
let b: group = Pedersen64::commit(i8_value, 1scalar);
let c: group = Pedersen64::commit(i16_value, 1scalar);
let d: group = Pedersen64::commit(i32_value, 1scalar);
let e: group = Pedersen64::commit(i64_value, 1scalar);
let f: group = Pedersen64::commit(u8_value, 1scalar);
let g: group = Pedersen64::commit(u16_value, 1scalar);
let h: group = Pedersen64::commit(u32_value, 1scalar);
let i: group = Pedersen64::commit(u64_value, 1scalar);
// let j11: group = Pedersen64::commit(string_value, 1scalar);
return a + i;
}

View File

@ -0,0 +1,9 @@
---
namespace: Compile
expectation: Pass
outputs:
- output:
- initial_input_ast: 5ea1607a031b1eaecb1b6aac13dae8c78f3fc15c5f9c7d8db94001539426f7eb
initial_ast: 5b6131efbfd5462882a2791a38480eb519989b0067a3edca457602208c478d86
unrolled_ast: 5b6131efbfd5462882a2791a38480eb519989b0067a3edca457602208c478d86
ssa_ast: d8cc8aa62944d6a0a296980b37043d6a4d55497cff78502295880c54effdf901

View File

@ -0,0 +1,9 @@
---
namespace: Compile
expectation: Pass
outputs:
- output:
- initial_input_ast: e3f5a66af9a0c987403e9ff8c0e084c127a374827259aca0e5b8f877a72700cf
initial_ast: 458a2e1a6ec5e5c3abc63180ed2aa0549f9a019c3fdb7733e873eab4fb6b2fdb
unrolled_ast: 458a2e1a6ec5e5c3abc63180ed2aa0549f9a019c3fdb7733e873eab4fb6b2fdb
ssa_ast: 49adc98be5feb00f1a99094e11ae3050a7810c2114d6c8c12c5e72fa7bd6b445