add digital signature inside program
This commit is contained in:
parent
0cbe93246b
commit
724a19bddb
8 changed files with 2009 additions and 468 deletions
|
@ -23,7 +23,7 @@ pub type Address = [u8; 20];
|
||||||
pub struct Obligation {
|
pub struct Obligation {
|
||||||
pub from: Address,
|
pub from: Address,
|
||||||
pub to: Address,
|
pub to: Address,
|
||||||
pub value: u8,
|
pub value: u8, // TODO: make this u32 or higher
|
||||||
pub salt: [u8; 32],
|
pub salt: [u8; 32],
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -35,9 +35,3 @@ pub struct Cycle {
|
||||||
pub size: usize,
|
pub size: usize,
|
||||||
pub obligations: ObligationList,
|
pub obligations: ObligationList,
|
||||||
}
|
}
|
||||||
|
|
||||||
// #[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
|
|
||||||
// pub struct SignedCommit {
|
|
||||||
// pub message: Digest,
|
|
||||||
// pub sign: Digest,
|
|
||||||
// }
|
|
||||||
|
|
12
cycle.json
12
cycle.json
|
@ -3,8 +3,8 @@
|
||||||
"size": 3,
|
"size": 3,
|
||||||
"obligations": [
|
"obligations": [
|
||||||
{
|
{
|
||||||
"from": "9BA1Bcd88E99d6E1E03252A70A63FEa83Bf1208c",
|
"from": [155, 161, 188, 216, 142, 153, 214, 225, 224, 50, 82, 167, 10, 99, 254, 168, 59, 241, 32, 140],
|
||||||
"to": "6FF840eeeFFec0C35F52bB6031a9Ae34524a05b6",
|
"to": [111, 248, 64, 238, 239, 254, 192, 195, 95, 82, 187, 96, 49, 169, 174, 52, 82, 74, 5, 182],
|
||||||
"value": 103,
|
"value": 103,
|
||||||
"salt": [
|
"salt": [
|
||||||
134,
|
134,
|
||||||
|
@ -42,8 +42,8 @@
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"from": "6FF840eeeFFec0C35F52bB6031a9Ae34524a05b6",
|
"from": [111, 248, 64, 238, 239, 254, 192, 195, 95, 82, 187, 96, 49, 169, 174, 52, 82, 74, 5, 182],
|
||||||
"to": "42cEDde51198D1773590311E2A340DC06B24cB37",
|
"to": [66, 206, 221, 229, 17, 152, 209, 119, 53, 144, 49, 30, 42, 52, 13, 192, 107, 36, 203, 55],
|
||||||
"value": 197,
|
"value": 197,
|
||||||
"salt": [
|
"salt": [
|
||||||
47,
|
47,
|
||||||
|
@ -81,8 +81,8 @@
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"from": "42cEDde51198D1773590311E2A340DC06B24cB37",
|
"from": [66, 206, 221, 229, 17, 152, 209, 119, 53, 144, 49, 30, 42, 52, 13, 192, 107, 36, 203, 55],
|
||||||
"to": "9BA1Bcd88E99d6E1E03252A70A63FEa83Bf1208c",
|
"to": [155, 161, 188, 216, 142, 153, 214, 225, 224, 50, 82, 167, 10, 99, 254, 168, 59, 241, 32, 140],
|
||||||
"value": 252,
|
"value": 252,
|
||||||
"salt": [
|
"salt": [
|
||||||
10,
|
10,
|
||||||
|
|
530
program/Cargo.lock
generated
530
program/Cargo.lock
generated
|
@ -4,9 +4,21 @@ version = 3
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "anyhow"
|
name = "anyhow"
|
||||||
version = "1.0.81"
|
version = "1.0.82"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "0952808a6c2afd1aa8947271f3a60f1a6763c7b912d210184c5149b5cf147247"
|
checksum = "f538837af36e6f6a9be0faa67f9a314f8119e4e4b5867c6ab40ed60360142519"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "arrayvec"
|
||||||
|
version = "0.7.4"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "96d30a06541fbafbc7f82ed10c06164cfbd2c401138f6addd8404629c4b16711"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "autocfg"
|
||||||
|
version = "1.2.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "f1fdabc7756949593fe60f30ec81974b613357de856987752631dea1e3394c80"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "base16ct"
|
name = "base16ct"
|
||||||
|
@ -59,6 +71,12 @@ dependencies = [
|
||||||
"generic-array",
|
"generic-array",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "byte-slice-cast"
|
||||||
|
version = "1.2.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "c3ac9f8b63eca6fd385229b3675f6cc0dc5c8a5c8a54a59d4f52ffd670d87b0c"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "byteorder"
|
name = "byteorder"
|
||||||
version = "1.5.0"
|
version = "1.5.0"
|
||||||
|
@ -111,8 +129,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "curve25519-dalek-ng"
|
name = "curve25519-dalek-ng"
|
||||||
version = "4.1.1"
|
version = "4.1.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "git+https://github.com/sp1-patches/curve25519-dalek-ng.git#01f43665631d2c33385708d41d0c26dbb1baa0ea"
|
||||||
checksum = "1c359b7249347e46fb28804470d071c921156ad62b3eef5d34e2ba867533dec8"
|
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"byteorder",
|
"byteorder",
|
||||||
"digest 0.9.0",
|
"digest 0.9.0",
|
||||||
|
@ -131,6 +148,17 @@ dependencies = [
|
||||||
"zeroize",
|
"zeroize",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "derive_more"
|
||||||
|
version = "0.99.17"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "4fb810d30a7c1953f91334de7244731fc3f3c10d7fe163338a35b9f640960321"
|
||||||
|
dependencies = [
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
"syn 1.0.109",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "digest"
|
name = "digest"
|
||||||
version = "0.9.0"
|
version = "0.9.0"
|
||||||
|
@ -169,18 +197,23 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ed25519-consensus"
|
name = "ed25519-consensus"
|
||||||
version = "2.1.0"
|
version = "2.1.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "git+https://github.com/sp1-patches/ed25519-consensus?branch=patch-v2.1.0#59f16610526726fa5c96dd77ca792f821021b66e"
|
||||||
checksum = "3c8465edc8ee7436ffea81d21a019b16676ee3db267aa8d5a8d729581ecf998b"
|
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"curve25519-dalek-ng",
|
"curve25519-dalek-ng",
|
||||||
"hex",
|
"hex",
|
||||||
"rand_core",
|
"rand_core",
|
||||||
"serde",
|
"serde",
|
||||||
"sha2 0.9.9",
|
"sha2 0.9.8",
|
||||||
"thiserror",
|
"thiserror",
|
||||||
"zeroize",
|
"zeroize",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "either"
|
||||||
|
version = "1.11.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "a47c1c47d2f5964e29c61246e81db715514cd532db6b5116a25ea3c03d6780a2"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "elliptic-curve"
|
name = "elliptic-curve"
|
||||||
version = "0.13.8"
|
version = "0.13.8"
|
||||||
|
@ -201,6 +234,12 @@ dependencies = [
|
||||||
"zeroize",
|
"zeroize",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "equivalent"
|
||||||
|
version = "1.0.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ff"
|
name = "ff"
|
||||||
version = "0.13.0"
|
version = "0.13.0"
|
||||||
|
@ -218,6 +257,12 @@ version = "2.0.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "e6d5a32815ae3f33302d95fdcb2ce17862f8c65363dcfd29360480ba1001fc9c"
|
checksum = "e6d5a32815ae3f33302d95fdcb2ce17862f8c65363dcfd29360480ba1001fc9c"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "gcd"
|
||||||
|
version = "2.3.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "1d758ba1b47b00caf47f24925c0074ecb20d6dfcffe7f6d53395c0465674841a"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "generic-array"
|
name = "generic-array"
|
||||||
version = "0.14.7"
|
version = "0.14.7"
|
||||||
|
@ -251,6 +296,12 @@ dependencies = [
|
||||||
"subtle",
|
"subtle",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "hashbrown"
|
||||||
|
version = "0.14.3"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "290f1a1d9242c78d09ce40a5e87e7554ee637af1351968159f4952f028f75604"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "hex"
|
name = "hex"
|
||||||
version = "0.4.3"
|
version = "0.4.3"
|
||||||
|
@ -266,6 +317,45 @@ dependencies = [
|
||||||
"digest 0.10.7",
|
"digest 0.10.7",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "impl-trait-for-tuples"
|
||||||
|
version = "0.2.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "11d7a9f6330b71fea57921c9b61c47ee6e84f72d394754eff6163ae67e7395eb"
|
||||||
|
dependencies = [
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
"syn 1.0.109",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "indexmap"
|
||||||
|
version = "2.2.6"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "168fb715dda47215e360912c096649d23d58bf392ac62f73919e831745e40f26"
|
||||||
|
dependencies = [
|
||||||
|
"equivalent",
|
||||||
|
"hashbrown",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "itertools"
|
||||||
|
version = "0.11.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "b1c173a5686ce8bfa551b3563d0c2170bf24ca44da99c7ca4bfdab5418c3fe57"
|
||||||
|
dependencies = [
|
||||||
|
"either",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "itertools"
|
||||||
|
version = "0.12.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "ba291022dbbd398a455acf126c1e341954079855bc60dfdda641363bd6922569"
|
||||||
|
dependencies = [
|
||||||
|
"either",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "k256"
|
name = "k256"
|
||||||
version = "0.13.3"
|
version = "0.13.3"
|
||||||
|
@ -280,6 +370,12 @@ dependencies = [
|
||||||
"signature",
|
"signature",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "lazy_static"
|
||||||
|
version = "1.4.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "libc"
|
name = "libc"
|
||||||
version = "0.2.153"
|
version = "0.2.153"
|
||||||
|
@ -292,6 +388,12 @@ version = "0.2.8"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "4ec2a862134d2a7d32d7983ddcdd1c4923530833c9f2ea1a44fc5fa473989058"
|
checksum = "4ec2a862134d2a7d32d7983ddcdd1c4923530833c9f2ea1a44fc5fa473989058"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "memchr"
|
||||||
|
version = "2.7.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "6c8640c5d730cb13ebd907d8d04b52f55ac9a2eec55b440c8892f40d56c76c1d"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "mtcs-core"
|
name = "mtcs-core"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
|
@ -311,6 +413,81 @@ dependencies = [
|
||||||
"sp1-zkvm",
|
"sp1-zkvm",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "num"
|
||||||
|
version = "0.4.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "3135b08af27d103b0a51f2ae0f8632117b7b185ccf931445affa8df530576a41"
|
||||||
|
dependencies = [
|
||||||
|
"num-bigint",
|
||||||
|
"num-complex",
|
||||||
|
"num-integer",
|
||||||
|
"num-iter",
|
||||||
|
"num-rational",
|
||||||
|
"num-traits",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "num-bigint"
|
||||||
|
version = "0.4.4"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "608e7659b5c3d7cba262d894801b9ec9d00de989e8a82bd4bef91d08da45cdc0"
|
||||||
|
dependencies = [
|
||||||
|
"autocfg",
|
||||||
|
"num-integer",
|
||||||
|
"num-traits",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "num-complex"
|
||||||
|
version = "0.4.5"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "23c6602fda94a57c990fe0df199a035d83576b496aa29f4e634a8ac6004e68a6"
|
||||||
|
dependencies = [
|
||||||
|
"num-traits",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "num-integer"
|
||||||
|
version = "0.1.46"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "7969661fd2958a5cb096e56c8e1ad0444ac2bbcd0061bd28660485a44879858f"
|
||||||
|
dependencies = [
|
||||||
|
"num-traits",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "num-iter"
|
||||||
|
version = "0.1.44"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "d869c01cc0c455284163fd0092f1f93835385ccab5a98a0dcc497b2f8bf055a9"
|
||||||
|
dependencies = [
|
||||||
|
"autocfg",
|
||||||
|
"num-integer",
|
||||||
|
"num-traits",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "num-rational"
|
||||||
|
version = "0.4.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "0638a1c9d0a3c0914158145bc76cff373a75a627e6ecbfb71cbe6f453a5a19b0"
|
||||||
|
dependencies = [
|
||||||
|
"autocfg",
|
||||||
|
"num-bigint",
|
||||||
|
"num-integer",
|
||||||
|
"num-traits",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "num-traits"
|
||||||
|
version = "0.2.18"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "da0df0e5185db44f69b44f26786fe401b6c293d1907744beaa7fa62b2e5a517a"
|
||||||
|
dependencies = [
|
||||||
|
"autocfg",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "once_cell"
|
name = "once_cell"
|
||||||
version = "1.19.0"
|
version = "1.19.0"
|
||||||
|
@ -323,6 +500,138 @@ version = "0.3.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "c08d65885ee38876c4f86fa503fb49d7b507c2b62552df7c70b2fce627e06381"
|
checksum = "c08d65885ee38876c4f86fa503fb49d7b507c2b62552df7c70b2fce627e06381"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "p3-baby-bear"
|
||||||
|
version = "0.1.0"
|
||||||
|
source = "git+https://github.com/Plonky3/Plonky3.git?branch=sp1#d379375a75417ddfd0a059ce7db63e162ec52c69"
|
||||||
|
dependencies = [
|
||||||
|
"num-bigint",
|
||||||
|
"p3-field",
|
||||||
|
"p3-mds",
|
||||||
|
"p3-poseidon2",
|
||||||
|
"p3-symmetric",
|
||||||
|
"rand",
|
||||||
|
"serde",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "p3-dft"
|
||||||
|
version = "0.1.0"
|
||||||
|
source = "git+https://github.com/Plonky3/Plonky3.git?branch=sp1#d379375a75417ddfd0a059ce7db63e162ec52c69"
|
||||||
|
dependencies = [
|
||||||
|
"p3-field",
|
||||||
|
"p3-matrix",
|
||||||
|
"p3-maybe-rayon",
|
||||||
|
"p3-util",
|
||||||
|
"tracing",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "p3-field"
|
||||||
|
version = "0.1.0"
|
||||||
|
source = "git+https://github.com/Plonky3/Plonky3.git?branch=sp1#d379375a75417ddfd0a059ce7db63e162ec52c69"
|
||||||
|
dependencies = [
|
||||||
|
"itertools 0.12.1",
|
||||||
|
"num-bigint",
|
||||||
|
"num-traits",
|
||||||
|
"p3-util",
|
||||||
|
"rand",
|
||||||
|
"serde",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "p3-matrix"
|
||||||
|
version = "0.1.0"
|
||||||
|
source = "git+https://github.com/Plonky3/Plonky3.git?branch=sp1#d379375a75417ddfd0a059ce7db63e162ec52c69"
|
||||||
|
dependencies = [
|
||||||
|
"itertools 0.12.1",
|
||||||
|
"p3-field",
|
||||||
|
"p3-maybe-rayon",
|
||||||
|
"p3-util",
|
||||||
|
"rand",
|
||||||
|
"serde",
|
||||||
|
"tracing",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "p3-maybe-rayon"
|
||||||
|
version = "0.1.0"
|
||||||
|
source = "git+https://github.com/Plonky3/Plonky3.git?branch=sp1#d379375a75417ddfd0a059ce7db63e162ec52c69"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "p3-mds"
|
||||||
|
version = "0.1.0"
|
||||||
|
source = "git+https://github.com/Plonky3/Plonky3.git?branch=sp1#d379375a75417ddfd0a059ce7db63e162ec52c69"
|
||||||
|
dependencies = [
|
||||||
|
"itertools 0.11.0",
|
||||||
|
"p3-dft",
|
||||||
|
"p3-field",
|
||||||
|
"p3-matrix",
|
||||||
|
"p3-symmetric",
|
||||||
|
"p3-util",
|
||||||
|
"rand",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "p3-poseidon2"
|
||||||
|
version = "0.1.0"
|
||||||
|
source = "git+https://github.com/Plonky3/Plonky3.git?branch=sp1#d379375a75417ddfd0a059ce7db63e162ec52c69"
|
||||||
|
dependencies = [
|
||||||
|
"gcd",
|
||||||
|
"p3-field",
|
||||||
|
"p3-mds",
|
||||||
|
"p3-symmetric",
|
||||||
|
"rand",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "p3-symmetric"
|
||||||
|
version = "0.1.0"
|
||||||
|
source = "git+https://github.com/Plonky3/Plonky3.git?branch=sp1#d379375a75417ddfd0a059ce7db63e162ec52c69"
|
||||||
|
dependencies = [
|
||||||
|
"itertools 0.12.1",
|
||||||
|
"p3-field",
|
||||||
|
"serde",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "p3-util"
|
||||||
|
version = "0.1.0"
|
||||||
|
source = "git+https://github.com/Plonky3/Plonky3.git?branch=sp1#d379375a75417ddfd0a059ce7db63e162ec52c69"
|
||||||
|
dependencies = [
|
||||||
|
"serde",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "parity-scale-codec"
|
||||||
|
version = "3.6.9"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "881331e34fa842a2fb61cc2db9643a8fedc615e47cfcc52597d1af0db9a7e8fe"
|
||||||
|
dependencies = [
|
||||||
|
"arrayvec",
|
||||||
|
"byte-slice-cast",
|
||||||
|
"impl-trait-for-tuples",
|
||||||
|
"parity-scale-codec-derive",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "parity-scale-codec-derive"
|
||||||
|
version = "3.6.9"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "be30eaf4b0a9fba5336683b38de57bb86d179a35862ba6bfcf57625d006bde5b"
|
||||||
|
dependencies = [
|
||||||
|
"proc-macro-crate 2.0.2",
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
"syn 1.0.109",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "pin-project-lite"
|
||||||
|
version = "0.2.14"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "bda66fc9667c18cb2758a2ac84d1167245054bcf85d5d1aaa6923f45801bdd02"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "pkcs8"
|
name = "pkcs8"
|
||||||
version = "0.10.2"
|
version = "0.10.2"
|
||||||
|
@ -340,19 +649,39 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de"
|
checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "proc-macro2"
|
name = "proc-macro-crate"
|
||||||
version = "1.0.79"
|
version = "1.3.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "e835ff2298f5721608eb1a980ecaee1aef2c132bf95ecc026a11b7bf3c01c02e"
|
checksum = "7f4c021e1093a56626774e81216a4ce732a735e5bad4868a03f3ed65ca0c3919"
|
||||||
|
dependencies = [
|
||||||
|
"once_cell",
|
||||||
|
"toml_edit 0.19.15",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "proc-macro-crate"
|
||||||
|
version = "2.0.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "b00f26d3400549137f92511a46ac1cd8ce37cb5598a96d382381458b992a5d24"
|
||||||
|
dependencies = [
|
||||||
|
"toml_datetime",
|
||||||
|
"toml_edit 0.20.2",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "proc-macro2"
|
||||||
|
version = "1.0.81"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "3d1597b0c024618f09a9c3b8655b7e430397a36d23fdafec26d6965e9eec3eba"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"unicode-ident",
|
"unicode-ident",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "quote"
|
name = "quote"
|
||||||
version = "1.0.35"
|
version = "1.0.36"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "291ec9ab5efd934aaf503a6466c5d5251535d108ee747472c3977cc5acc868ef"
|
checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
]
|
]
|
||||||
|
@ -412,6 +741,30 @@ dependencies = [
|
||||||
"sha2 0.10.8",
|
"sha2 0.10.8",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "scale-info"
|
||||||
|
version = "2.11.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "7c453e59a955f81fb62ee5d596b450383d699f152d350e9d23a0db2adb78e4c0"
|
||||||
|
dependencies = [
|
||||||
|
"cfg-if",
|
||||||
|
"derive_more",
|
||||||
|
"parity-scale-codec",
|
||||||
|
"scale-info-derive",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "scale-info-derive"
|
||||||
|
version = "2.11.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "18cf6c6447f813ef19eb450e985bcce6705f9ce7660db221b59093d15c79c4b7"
|
||||||
|
dependencies = [
|
||||||
|
"proc-macro-crate 1.3.1",
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
"syn 1.0.109",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "sec1"
|
name = "sec1"
|
||||||
version = "0.7.3"
|
version = "0.7.3"
|
||||||
|
@ -428,29 +781,28 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "serde"
|
name = "serde"
|
||||||
version = "1.0.197"
|
version = "1.0.198"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "3fb1c873e1b9b056a4dc4c0c198b24c3ffa059243875552b2bd0933b1aee4ce2"
|
checksum = "9846a40c979031340571da2545a4e5b7c4163bdae79b301d5f86d03979451fcc"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"serde_derive",
|
"serde_derive",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "serde_derive"
|
name = "serde_derive"
|
||||||
version = "1.0.197"
|
version = "1.0.198"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "7eb0b34b42edc17f6b7cac84a52a1c5f0e1bb2227e997ca9011ea3dd34e8610b"
|
checksum = "e88edab869b01783ba905e7d0153f9fc1a6505a96e4ad3018011eedb838566d9"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn",
|
"syn 2.0.60",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "sha2"
|
name = "sha2"
|
||||||
version = "0.9.9"
|
version = "0.9.8"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "git+https://github.com/sp1-patches/RustCrypto-hashes?branch=patch-v0.9.8#0b578688db61bb53e15353f5beaa2c11ad93f037"
|
||||||
checksum = "4d58a1e1bf39749807d89cf2d98ac2dfa0ff1cb3faa38fbb64dd88ac8013d800"
|
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"block-buffer 0.9.0",
|
"block-buffer 0.9.0",
|
||||||
"cfg-if",
|
"cfg-if",
|
||||||
|
@ -479,24 +831,50 @@ dependencies = [
|
||||||
"rand_core",
|
"rand_core",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "snowbridge-amcl"
|
||||||
|
version = "1.0.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "460a9ed63cdf03c1b9847e8a12a5f5ba19c4efd5869e4a737e05be25d7c427e5"
|
||||||
|
dependencies = [
|
||||||
|
"parity-scale-codec",
|
||||||
|
"scale-info",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "sp1-precompiles"
|
name = "sp1-precompiles"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
source = "git+https://github.com/succinctlabs/sp1.git#b5d5473c010ab0630102652146e16c014a1eddf6"
|
source = "git+https://github.com/succinctlabs/sp1.git#3c8fee52c9d9d33c9b2e3aa5a9cbe0f8265c7af1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"bincode",
|
"bincode",
|
||||||
"cfg-if",
|
"cfg-if",
|
||||||
"getrandom",
|
"getrandom",
|
||||||
|
"hex",
|
||||||
"k256",
|
"k256",
|
||||||
|
"num",
|
||||||
"rand",
|
"rand",
|
||||||
"serde",
|
"serde",
|
||||||
|
"snowbridge-amcl",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "sp1-primitives"
|
||||||
|
version = "0.1.0"
|
||||||
|
source = "git+https://github.com/succinctlabs/sp1.git#3c8fee52c9d9d33c9b2e3aa5a9cbe0f8265c7af1"
|
||||||
|
dependencies = [
|
||||||
|
"itertools 0.12.1",
|
||||||
|
"lazy_static",
|
||||||
|
"p3-baby-bear",
|
||||||
|
"p3-field",
|
||||||
|
"p3-poseidon2",
|
||||||
|
"p3-symmetric",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "sp1-zkvm"
|
name = "sp1-zkvm"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
source = "git+https://github.com/succinctlabs/sp1.git#b5d5473c010ab0630102652146e16c014a1eddf6"
|
source = "git+https://github.com/succinctlabs/sp1.git#3c8fee52c9d9d33c9b2e3aa5a9cbe0f8265c7af1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bincode",
|
"bincode",
|
||||||
"cfg-if",
|
"cfg-if",
|
||||||
|
@ -504,10 +882,13 @@ dependencies = [
|
||||||
"k256",
|
"k256",
|
||||||
"libm",
|
"libm",
|
||||||
"once_cell",
|
"once_cell",
|
||||||
|
"p3-baby-bear",
|
||||||
|
"p3-field",
|
||||||
"rand",
|
"rand",
|
||||||
"serde",
|
"serde",
|
||||||
"sha2 0.10.8",
|
"sha2 0.10.8",
|
||||||
"sp1-precompiles",
|
"sp1-precompiles",
|
||||||
|
"sp1-primitives",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -534,9 +915,20 @@ checksum = "734676eb262c623cec13c3155096e08d1f8f29adce39ba17948b18dad1e54142"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "syn"
|
name = "syn"
|
||||||
version = "2.0.58"
|
version = "1.0.109"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "44cfb93f38070beee36b3fef7d4f5a16f27751d94b187b666a5cc5e9b0d30687"
|
checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237"
|
||||||
|
dependencies = [
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
"unicode-ident",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "syn"
|
||||||
|
version = "2.0.60"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "909518bc7b1c9b779f1bbf07f2929d35af9f0f37e47c6e9ef7f9dddc1e1821f3"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
|
@ -566,7 +958,66 @@ checksum = "c61f3ba182994efc43764a46c018c347bc492c79f024e705f46567b418f6d4f7"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn",
|
"syn 2.0.60",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "toml_datetime"
|
||||||
|
version = "0.6.3"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "7cda73e2f1397b1262d6dfdcef8aafae14d1de7748d66822d3bfeeb6d03e5e4b"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "toml_edit"
|
||||||
|
version = "0.19.15"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "1b5bb770da30e5cbfde35a2d7b9b8a2c4b8ef89548a7a6aeab5c9a576e3e7421"
|
||||||
|
dependencies = [
|
||||||
|
"indexmap",
|
||||||
|
"toml_datetime",
|
||||||
|
"winnow",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "toml_edit"
|
||||||
|
version = "0.20.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "396e4d48bbb2b7554c944bde63101b5ae446cff6ec4a24227428f15eb72ef338"
|
||||||
|
dependencies = [
|
||||||
|
"indexmap",
|
||||||
|
"toml_datetime",
|
||||||
|
"winnow",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "tracing"
|
||||||
|
version = "0.1.40"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "c3523ab5a71916ccf420eebdf5521fcef02141234bbc0b8a49f2fdc4544364ef"
|
||||||
|
dependencies = [
|
||||||
|
"pin-project-lite",
|
||||||
|
"tracing-attributes",
|
||||||
|
"tracing-core",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "tracing-attributes"
|
||||||
|
version = "0.1.27"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7"
|
||||||
|
dependencies = [
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
"syn 2.0.60",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "tracing-core"
|
||||||
|
version = "0.1.32"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "c06d3da6113f116aaee68e4d601191614c9053067f9ab7f6edbcb161237daa54"
|
||||||
|
dependencies = [
|
||||||
|
"once_cell",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -593,6 +1044,15 @@ version = "0.11.0+wasi-snapshot-preview1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423"
|
checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "winnow"
|
||||||
|
version = "0.5.40"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "f593a95398737aeed53e489c785df13f3618e41dbcd6718c6addbf1395aa6876"
|
||||||
|
dependencies = [
|
||||||
|
"memchr",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "wyz"
|
name = "wyz"
|
||||||
version = "0.5.1"
|
version = "0.5.1"
|
||||||
|
@ -607,3 +1067,23 @@ name = "zeroize"
|
||||||
version = "1.7.0"
|
version = "1.7.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "525b4ec142c6b68a2d10f01f7bbf6755599ca3f81ea53b8431b7dd348f5fdb2d"
|
checksum = "525b4ec142c6b68a2d10f01f7bbf6755599ca3f81ea53b8431b7dd348f5fdb2d"
|
||||||
|
|
||||||
|
[[patch.unused]]
|
||||||
|
name = "curve25519-dalek"
|
||||||
|
version = "4.1.1"
|
||||||
|
source = "git+https://github.com/sp1-patches/curve25519-dalek?branch=patch-v4.1.1#c226f30522c9e4123ffce4302ed210075acf741e"
|
||||||
|
|
||||||
|
[[patch.unused]]
|
||||||
|
name = "curve25519-dalek-ng"
|
||||||
|
version = "4.1.1"
|
||||||
|
source = "git+https://github.com/sp1-patches/curve25519-dalek-ng?branch=patch-v4.1.1#1e6069f81e4497d04a16b90001f0e61f3440f263"
|
||||||
|
|
||||||
|
[[patch.unused]]
|
||||||
|
name = "sha2"
|
||||||
|
version = "0.10.6"
|
||||||
|
source = "git+https://github.com/sp1-patches/RustCrypto-hashes?branch=patch-v0.10.6#482efd7c1a750c300f3740a2c75dda9eb4eb1ddd"
|
||||||
|
|
||||||
|
[[patch.unused]]
|
||||||
|
name = "tiny-keccak"
|
||||||
|
version = "2.0.2"
|
||||||
|
source = "git+https://github.com/sp1-patches/tiny-keccak?branch=patch-v2.0.2#aa70bacdfece9dc7ea4936f808887c43a09b3b0a"
|
||||||
|
|
|
@ -13,4 +13,10 @@ ed25519-consensus = "2.1"
|
||||||
rand = "0.8.5"
|
rand = "0.8.5"
|
||||||
|
|
||||||
[patch.crates-io]
|
[patch.crates-io]
|
||||||
|
sha2-v0-9-8 = { git = "https://github.com/sp1-patches/RustCrypto-hashes", package = "sha2", branch = "patch-v0.9.8" }
|
||||||
|
sha2-v0-10-6 = { git = "https://github.com/sp1-patches/RustCrypto-hashes", package = "sha2", branch = "patch-v0.10.6" }
|
||||||
sha2-v0-10-8 = { git = "https://github.com/sp1-patches/RustCrypto-hashes", package = "sha2", branch = "patch-v0.10.8" }
|
sha2-v0-10-8 = { git = "https://github.com/sp1-patches/RustCrypto-hashes", package = "sha2", branch = "patch-v0.10.8" }
|
||||||
|
curve25519-dalek = { git = "https://github.com/sp1-patches/curve25519-dalek", branch = "patch-v4.1.1" }
|
||||||
|
curve25519-dalek-ng = { git = "https://github.com/sp1-patches/curve25519-dalek-ng", branch = "patch-v4.1.1" }
|
||||||
|
ed25519-consensus = { git = "https://github.com/sp1-patches/ed25519-consensus", branch = "patch-v2.1.0" }
|
||||||
|
tiny-keccak = { git = "https://github.com/sp1-patches/tiny-keccak", branch = "patch-v2.0.2" }
|
||||||
|
|
|
@ -4,7 +4,7 @@ use bincode::serialize;
|
||||||
use ed25519_consensus::*;
|
use ed25519_consensus::*;
|
||||||
use mtcs_core::*;
|
use mtcs_core::*;
|
||||||
use rand::thread_rng;
|
use rand::thread_rng;
|
||||||
use rs_merkle::{algorithms::Sha256 as MerkleSha256, Hasher, MerkleProof};
|
use rs_merkle::{algorithms::Sha256, Hasher, MerkleProof};
|
||||||
sp1_zkvm::entrypoint!(main);
|
sp1_zkvm::entrypoint!(main);
|
||||||
|
|
||||||
pub fn main() {
|
pub fn main() {
|
||||||
|
@ -32,7 +32,7 @@ pub fn main() {
|
||||||
|
|
||||||
let to = &cycle.obligations.iter().fold(from, |acc, x| {
|
let to = &cycle.obligations.iter().fold(from, |acc, x| {
|
||||||
if &x.from == acc && &x.value >= &cycle.setoff {
|
if &x.from == acc && &x.value >= &cycle.setoff {
|
||||||
leaves.push(MerkleSha256::hash(&serialize(&x).unwrap()));
|
leaves.push(Sha256::hash(&serialize(&x).unwrap()));
|
||||||
&x.to
|
&x.to
|
||||||
} else {
|
} else {
|
||||||
panic!("cycle invalid")
|
panic!("cycle invalid")
|
||||||
|
@ -41,27 +41,27 @@ pub fn main() {
|
||||||
|
|
||||||
assert_eq!(&from, to);
|
assert_eq!(&from, to);
|
||||||
let indexes = merkle_data.indexes;
|
let indexes = merkle_data.indexes;
|
||||||
let proof: MerkleProof<MerkleSha256> =
|
let proof: MerkleProof<Sha256> = MerkleProof::<Sha256>::try_from(proof.bytes).unwrap();
|
||||||
MerkleProof::<MerkleSha256>::try_from(proof.bytes).unwrap();
|
|
||||||
assert!(proof.verify(
|
assert!(proof.verify(
|
||||||
merkle_data.merkle_root,
|
merkle_data.merkle_root,
|
||||||
&indexes,
|
&indexes,
|
||||||
leaves.get(..).ok_or("couldn't fetch leaves").unwrap(),
|
leaves.get(..).ok_or("couldn't fetch leaves").unwrap(),
|
||||||
merkle_data.len
|
merkle_data.len
|
||||||
));
|
));
|
||||||
println!("creating commitments for public data");
|
println!("creating commitments for public data...");
|
||||||
|
|
||||||
let (vk_bytes, sig) = {
|
let message = {
|
||||||
|
let hashed_cycle = Sha256::hash(&serialize(&cycle).unwrap());
|
||||||
// Generate a signing key and sign the message
|
// Generate a signing key and sign the message
|
||||||
let sk = SigningKey::new(thread_rng());
|
let sk = SigningKey::new(thread_rng());
|
||||||
let sig = sk.sign(&bincode::serialize(&cycle).unwrap()[..]);
|
let sig = sk.sign(&bincode::serialize(&hashed_cycle).unwrap()[..]);
|
||||||
|
|
||||||
let vk_bytes: [u8; 32] = VerificationKey::from(&sk).into();
|
let vk_bytes: [u8; 32] = VerificationKey::from(&sk).into();
|
||||||
|
|
||||||
(vk_bytes, sig)
|
(hashed_cycle, vk_bytes, sig)
|
||||||
};
|
};
|
||||||
sp1_zkvm::io::commit(&vk_bytes);
|
|
||||||
sp1_zkvm::io::commit(&sig);
|
sp1_zkvm::io::commit(&message);
|
||||||
}
|
}
|
||||||
// TODO: for every edge involved in clearing, the total offsets of all cycles
|
// TODO: for every edge involved in clearing, the total offsets of all cycles
|
||||||
// passing through that edge should be less than the value of that edge
|
// passing through that edge should be less than the value of that edge
|
||||||
|
|
1773
script/Cargo.lock
generated
1773
script/Cargo.lock
generated
File diff suppressed because it is too large
Load diff
|
@ -11,6 +11,7 @@ rs_merkle = "1.4.2"
|
||||||
bincode = "1.3.3"
|
bincode = "1.3.3"
|
||||||
hex = "0.4.3"
|
hex = "0.4.3"
|
||||||
serde_json = "1.0"
|
serde_json = "1.0"
|
||||||
|
ed25519-consensus = "2.1.0"
|
||||||
|
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
sp1-helper = { git = "https://github.com/succinctlabs/sp1.git" }
|
sp1-helper = { git = "https://github.com/succinctlabs/sp1.git" }
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
// These constants represent the RISC-V ELF and the image ID generated by risc0-build.
|
// These constants represent the RISC-V ELF and the image ID generated by risc0-build.
|
||||||
// The ELF is used for proving and the ID is used for verification.
|
// The ELF is used for proving and the ID is used for verification.
|
||||||
use bincode::serialize;
|
use bincode::serialize;
|
||||||
|
use ed25519_consensus::*;
|
||||||
use mtcs_core::*;
|
use mtcs_core::*;
|
||||||
//use std::fs;
|
|
||||||
|
|
||||||
use rs_merkle::{algorithms::Sha256 as MerkleSha256, Hasher, MerkleTree};
|
use rs_merkle::{algorithms::Sha256 as MerkleSha256, Hasher, MerkleTree};
|
||||||
|
use std::fs;
|
||||||
use std::time::SystemTime;
|
use std::time::SystemTime;
|
||||||
|
|
||||||
use sp1_sdk::{utils, SP1Prover, SP1Stdin, SP1Verifier};
|
use sp1_sdk::{utils, ProverClient, SP1Stdin};
|
||||||
|
|
||||||
const ELF: &[u8] = include_bytes!("../../program/elf/riscv32im-succinct-zkvm-elf");
|
const ELF: &[u8] = include_bytes!("../../program/elf/riscv32im-succinct-zkvm-elf");
|
||||||
|
|
||||||
|
@ -20,63 +20,64 @@ fn main() {
|
||||||
let key: Vec<u8> = "passw0rdpassw0rdpassw0rdpassw0rd".as_bytes().to_vec();
|
let key: Vec<u8> = "passw0rdpassw0rdpassw0rdpassw0rd".as_bytes().to_vec();
|
||||||
|
|
||||||
let secret = PrivateKey { key };
|
let secret = PrivateKey { key };
|
||||||
// let cycle_data: String = fs::read_to_string("../cycle.json").unwrap();
|
let cycle_data: String = fs::read_to_string("../cycle.json").unwrap();
|
||||||
|
|
||||||
// let cycle: Cycle = serde_json::from_str(&cycle_file.to_owned()).expect("JSON not well formatted");
|
let cycle: Cycle =
|
||||||
|
serde_json::from_str(&cycle_data.to_owned()).expect("JSON not well formatted");
|
||||||
// let all_obligations: Vec<Obligation> = serde_json::from_str("obligations.json").expect("JSON was not well-formatted");
|
// let all_obligations: Vec<Obligation> = serde_json::from_str("obligations.json").expect("JSON was not well-formatted");
|
||||||
|
|
||||||
let cycle: Cycle = Cycle {
|
// let cycle: Cycle = Cycle {
|
||||||
setoff: 103,
|
// setoff: 103,
|
||||||
size: 3,
|
// size: 3,
|
||||||
obligations: vec![
|
// obligations: vec![
|
||||||
Obligation {
|
// Obligation {
|
||||||
from: hex::decode("9BA1Bcd88E99d6E1E03252A70A63FEa83Bf1208c")
|
// from: hex::decode("9BA1Bcd88E99d6E1E03252A70A63FEa83Bf1208c")
|
||||||
.expect("Decoding failed")
|
// .expect("Decoding failed")
|
||||||
.try_into()
|
// .try_into()
|
||||||
.unwrap(),
|
// .unwrap(),
|
||||||
to: hex::decode("6FF840eeeFFec0C35F52bB6031a9Ae34524a05b6")
|
// to: hex::decode("6FF840eeeFFec0C35F52bB6031a9Ae34524a05b6")
|
||||||
.expect("Decoding failed")
|
// .expect("Decoding failed")
|
||||||
.try_into()
|
// .try_into()
|
||||||
.unwrap(),
|
// .unwrap(),
|
||||||
value: 103,
|
// value: 103,
|
||||||
salt: [
|
// salt: [
|
||||||
134, 104, 222, 91, 13, 97, 183, 43, 190, 29, 199, 203, 206, 17, 241, 117, 145,
|
// 134, 104, 222, 91, 13, 97, 183, 43, 190, 29, 199, 203, 206, 17, 241, 117, 145,
|
||||||
238, 154, 201, 79, 48, 188, 175, 205, 156, 218, 223, 93, 208, 253, 13,
|
// 238, 154, 201, 79, 48, 188, 175, 205, 156, 218, 223, 93, 208, 253, 13,
|
||||||
],
|
// ],
|
||||||
},
|
// },
|
||||||
Obligation {
|
// Obligation {
|
||||||
from: hex::decode("6FF840eeeFFec0C35F52bB6031a9Ae34524a05b6")
|
// from: hex::decode("6FF840eeeFFec0C35F52bB6031a9Ae34524a05b6")
|
||||||
.expect("Decoding failed")
|
// .expect("Decoding failed")
|
||||||
.try_into()
|
// .try_into()
|
||||||
.unwrap(),
|
// .unwrap(),
|
||||||
to: hex::decode("42cEDde51198D1773590311E2A340DC06B24cB37")
|
// to: hex::decode("42cEDde51198D1773590311E2A340DC06B24cB37")
|
||||||
.expect("Decoding failed")
|
// .expect("Decoding failed")
|
||||||
.try_into()
|
// .try_into()
|
||||||
.unwrap(),
|
// .unwrap(),
|
||||||
value: 197,
|
// value: 197,
|
||||||
salt: [
|
// salt: [
|
||||||
47, 45, 177, 118, 3, 36, 136, 70, 238, 148, 143, 56, 140, 115, 20, 16, 235,
|
// 47, 45, 177, 118, 3, 36, 136, 70, 238, 148, 143, 56, 140, 115, 20, 16, 235,
|
||||||
102, 188, 236, 119, 192, 25, 103, 197, 72, 237, 170, 40, 203, 125, 227,
|
// 102, 188, 236, 119, 192, 25, 103, 197, 72, 237, 170, 40, 203, 125, 227,
|
||||||
],
|
// ],
|
||||||
},
|
// },
|
||||||
Obligation {
|
// Obligation {
|
||||||
from: hex::decode("42cEDde51198D1773590311E2A340DC06B24cB37")
|
// from: hex::decode("42cEDde51198D1773590311E2A340DC06B24cB37")
|
||||||
.expect("Decoding failed")
|
// .expect("Decoding failed")
|
||||||
.try_into()
|
// .try_into()
|
||||||
.unwrap(),
|
// .unwrap(),
|
||||||
|
|
||||||
to: hex::decode("9BA1Bcd88E99d6E1E03252A70A63FEa83Bf1208c")
|
// to: hex::decode("9BA1Bcd88E99d6E1E03252A70A63FEa83Bf1208c")
|
||||||
.expect("Decoding failed")
|
// .expect("Decoding failed")
|
||||||
.try_into()
|
// .try_into()
|
||||||
.unwrap(),
|
// .unwrap(),
|
||||||
value: 252,
|
// value: 252,
|
||||||
salt: [
|
// salt: [
|
||||||
10, 136, 55, 248, 203, 115, 181, 120, 254, 162, 89, 219, 109, 241, 31, 169,
|
// 10, 136, 55, 248, 203, 115, 181, 120, 254, 162, 89, 219, 109, 241, 31, 169,
|
||||||
203, 202, 197, 34, 2, 240, 234, 36, 28, 103, 3, 184, 190, 156, 151, 252,
|
// 203, 202, 197, 34, 2, 240, 234, 36, 28, 103, 3, 184, 190, 156, 151, 252,
|
||||||
],
|
// ],
|
||||||
},
|
// },
|
||||||
],
|
// ],
|
||||||
};
|
// };
|
||||||
|
|
||||||
let all_obligations: Vec<Obligation> = vec![
|
let all_obligations: Vec<Obligation> = vec![
|
||||||
Obligation {
|
Obligation {
|
||||||
|
@ -159,6 +160,7 @@ fn main() {
|
||||||
};
|
};
|
||||||
|
|
||||||
let mut stdin = SP1Stdin::new();
|
let mut stdin = SP1Stdin::new();
|
||||||
|
let client = ProverClient::new();
|
||||||
|
|
||||||
println!("writing inputs to guest...");
|
println!("writing inputs to guest...");
|
||||||
stdin.write(&cycle);
|
stdin.write(&cycle);
|
||||||
|
@ -168,14 +170,21 @@ fn main() {
|
||||||
|
|
||||||
println!("generating proof...");
|
println!("generating proof...");
|
||||||
|
|
||||||
let proof = SP1Prover::prove(ELF, stdin).expect("proving failed");
|
let mut proof = client.prove(ELF, stdin).expect("proving failed");
|
||||||
|
|
||||||
println!("proof generation completed!");
|
println!("proof generation completed!");
|
||||||
|
|
||||||
println!("verifying receipt...");
|
println!("verifying receipt...");
|
||||||
SP1Verifier::verify(ELF, &proof).expect("verification failed");
|
client.verify(ELF, &proof).expect("verification failed");
|
||||||
println!("verification completed!");
|
println!("verification completed!");
|
||||||
|
|
||||||
|
println!("validating digital signature...");
|
||||||
|
|
||||||
|
let (hash, verification_key, sign): &([u8; 32], VerificationKey, Signature) =
|
||||||
|
&proof.public_values.read();
|
||||||
|
// let read_values: ([u8; 32], Signature) = pub_values.read();
|
||||||
|
let sig_verify = verification_key.verify(sign, hash).is_ok();
|
||||||
|
assert!(sig_verify);
|
||||||
let end_time = SystemTime::now();
|
let end_time = SystemTime::now();
|
||||||
let difference = end_time
|
let difference = end_time
|
||||||
.duration_since(start_time)
|
.duration_since(start_time)
|
||||||
|
@ -186,5 +195,5 @@ fn main() {
|
||||||
.save("proof-with-io.json")
|
.save("proof-with-io.json")
|
||||||
.expect("saving proof failed");
|
.expect("saving proof failed");
|
||||||
|
|
||||||
println!("successfully generated and verified proof for the program!")
|
println!("successfully generated and verified proof for cycle validity!")
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue