Skip to content
This repository has been archived by the owner on Aug 30, 2024. It is now read-only.

refactor: utils, step, signature, voting #10

Merged
merged 64 commits into from
Aug 11, 2023
Merged
Show file tree
Hide file tree
Changes from 62 commits
Commits
Show all changes
64 commits
Select commit Hold shift + click to select a range
21cbe82
use generic types
ratankaliani Jul 28, 2023
1346f0a
feat: read signed block from rpc
ratankaliani Jul 28, 2023
a8f3d5a
feat: get merkle encoding, matches marshal tendermint val
ratankaliani Jul 28, 2023
a537988
feat: Verifying signatures from the celestia val set
ratankaliani Jul 31, 2023
41d1112
refactor: cleanup
ratankaliani Jul 31, 2023
e1e7f81
feat: Add simple circuit to verify header hash matches the correspond…
ratankaliani Aug 1, 2023
674ba4e
verify header in message
ratankaliani Aug 1, 2023
ab6c61c
feat: moved inner hash to separate fn, testing get_root_from_merkle_p…
ratankaliani Aug 1, 2023
3762572
got merkle leaf proof to verify
ratankaliani Aug 2, 2023
fcd577e
refactor: simplify testing for different fields (data hash, next vali…
ratankaliani Aug 2, 2023
2b1e38c
lint
ratankaliani Aug 2, 2023
2505499
rm voting file
ratankaliani Aug 2, 2023
24eb6bc
feat: add prints to merkle
ratankaliani Aug 2, 2023
9dfe40a
feat: add subcircuit to check total voting power
ratankaliani Aug 2, 2023
bba23c9
feat: generate inputs, update cargo lock
ratankaliani Aug 3, 2023
dceee7f
lint
ratankaliani Aug 3, 2023
135ec27
style: lint
ratankaliani Aug 3, 2023
5a22ef1
chore: update pkgs
ratankaliani Aug 3, 2023
cb75cdc
lint, merge
ratankaliani Aug 3, 2023
02f947f
wip: adding field traits
ratankaliani Aug 3, 2023
e2c1ebe
merge, fix test paths
ratankaliani Aug 3, 2023
997e800
Merge remote-tracking branch 'origin/ratan/generate-inputs' into rata…
ratankaliani Aug 3, 2023
0c212ba
feat: verify sig
ratankaliani Aug 5, 2023
cbe22b8
get all validator pubkeys, signed votes and signatures
ratankaliani Aug 5, 2023
d2c2d70
new val test
ratankaliani Aug 5, 2023
cd2548f
write sigs to file
ratankaliani Aug 5, 2023
995d8c6
bug: pubkey equivocation check failing
ratankaliani Aug 6, 2023
2ce7fd6
add scaffold for verifyblock method
ratankaliani Aug 7, 2023
e3d3f11
feat: got verify sig working
ratankaliani Aug 7, 2023
918c692
lint
ratankaliani Aug 7, 2023
b1a5a2e
use affine point target in Tendermint validator
ratankaliani Aug 7, 2023
485f096
remove byte representation of pubkey
ratankaliani Aug 7, 2023
9c8f710
refactor: use set_affine_point_target
ratankaliani Aug 8, 2023
b16608b
refactor: use set_affine_point_target
ratankaliani Aug 8, 2023
6958b3b
refactor: add target wrapper for booltarget arrays
ratankaliani Aug 8, 2023
44633f8
replace bool target arr with tendermintHashTarget
ratankaliani Aug 8, 2023
16b6948
feat: finish scaffold
ratankaliani Aug 8, 2023
ccf397e
fix: add make_validators_circuit virtual targets
ratankaliani Aug 8, 2023
f31fa02
chore: cargo fmt
ratankaliani Aug 8, 2023
b76efc9
refactor: pass refs instead of objs
ratankaliani Aug 8, 2023
ba324b1
merge, add msg byte length
ratankaliani Aug 8, 2023
6b09a05
attempting to test small header
ratankaliani Aug 9, 2023
e036413
generate merkle root passes
ratankaliani Aug 9, 2023
254bbcd
update inputs
ratankaliani Aug 9, 2023
e0394fe
wip: trying to verify just the merkle proofs using test_step
ratankaliani Aug 9, 2023
41a0dcf
fix: set virtual targets correctly, wip: test_step
ratankaliani Aug 9, 2023
7298dd2
wip: working on step
ratankaliani Aug 9, 2023
6263395
verified signatures
ratankaliani Aug 9, 2023
ad21bd3
lint
ratankaliani Aug 9, 2023
827b359
wip: debugging val hash and extracted val hash
ratankaliani Aug 10, 2023
0128c6a
wip: fixed marshal tendermint validator working on using le bits
ratankaliani Aug 10, 2023
c7f5538
verify small header!
ratankaliani Aug 10, 2023
7ed5c15
verify step, uncomment all parts
ratankaliani Aug 10, 2023
d3ec95b
chore: cargo fmt
ratankaliani Aug 10, 2023
d8da07d
cleanup
ratankaliani Aug 11, 2023
1c4d4e6
migrate non-circuit utils into utils
ratankaliani Aug 11, 2023
15b837b
refactor: organize functionality by file, new traits
ratankaliani Aug 11, 2023
411ccf9
chore: cargo fmt
ratankaliani Aug 11, 2023
ca26dcb
refactor: clean up generate val hash
ratankaliani Aug 11, 2023
cf3ac53
lint
ratankaliani Aug 11, 2023
93be33b
merge
ratankaliani Aug 11, 2023
819bc79
chore: cargo update
ratankaliani Aug 11, 2023
edde8bb
merge
ratankaliani Aug 11, 2023
59bd275
wip: need to run tests
ratankaliani Aug 11, 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
2,247 changes: 2,167 additions & 80 deletions Cargo.lock

Large diffs are not rendered by default.

6 changes: 5 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,13 @@ edition = "2021"
[dependencies]
anyhow = "1.0.71"
clap = { version = "4.3.18", features = ["derive"] }
curta = { git = "https://github.com/succinctlabs/curta.git" }
digest = "0.10.7"
env_logger = "0.10.0"
log = "0.4.19"
num = "0.4.1"
plonky2 = { git = "https://github.com/mir-protocol/plonky2.git" }
plonky2_gadgets = { git = "ssh://git@github.com/succinctlabs/plonky2-gadgets.git" }
plonky2x = { git = "ssh://git@github.com/succinctlabs/sdk.git" }
rand = "0.8.5"
reqwest = "0.11.18"
serde = "1.0.175"
Expand Down
1 change: 0 additions & 1 deletion src/fixtures.rs

This file was deleted.

117 changes: 117 additions & 0 deletions src/fixtures/11000/signed_block.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
{
"header": {
"version": {
"block": "11",
"app": "1"
},
"chain_id": "mocha-3",
"height": "11000",
"time": "2023-07-05T20:54:13.892534239Z",
"last_block_id": {
"hash": "56161B10D4C4947176453C1368F77365A44EA9DAE32D9E5B49D6B9A1C6E0D85A",
"parts": {
"total": 1,
"hash": "58B433B2A584B221C29FE822354E8CFF1D91FCC7EF41341CB7D802E53A445201"
}
},
"last_commit_hash": "1E5088BBE20136F8AF4B52159779AA3CA0659C5968F84E25DD292BDD18A8289C",
"data_hash": "3D96B7D238E7E0456F6AF8E7CDF0A67BD6CF9C2089ECB559C659DCAA1F880353",
"validators_hash": "BB5B8B1239565451DCD5AB52B47C26032016CDF1EF2D2115FF104DC9DDE3988C",
"next_validators_hash": "BB5B8B1239565451DCD5AB52B47C26032016CDF1EF2D2115FF104DC9DDE3988C",
"consensus_hash": "C0B6A634B72AE9687EA53B6D277A73ABA1386BA3CFC6D0F26963602F7F6FFCD6",
"app_hash": "8CF46185F4737417CA28709E5EB2F68BBA6B61675286471E5E3412B021C43436",
"last_results_hash": "E3B0C44298FC1C149AFBF4C8996FB92427AE41E4649B934CA495991B7852B855",
"evidence_hash": "E3B0C44298FC1C149AFBF4C8996FB92427AE41E4649B934CA495991B7852B855",
"proposer_address": "81A24EE534DEFE1557A4C7C437E8E8FBC2F834E8"
},
"data": {
"txs": null
},
"commit": {
"height": "11000",
"round": 0,
"block_id": {
"hash": "36F2D954FE1BA37C5036CB3C6B366D0DAF68FCCBAA370D9490361C51A0A38B61",
"parts": {
"total": 1,
"hash": "CDDF370E891591C9D912AF175C966CD8DFA44B2C517E965416B769EB4B9D5D8D"
}
},
"signatures": [
{
"block_id_flag": 2,
"validator_address": "81A24EE534DEFE1557A4C7C437E8E8FBC2F834E8",
"timestamp": "2023-07-05T20:54:14.892534239Z",
"signature": "CRV26eOtDlumYfc5jhrbOXa6ZHtXm45KIk0dArWRreau25TTv1XSWPCJ1kExVaV639STJBinmMLWiymFD2+1Cw=="
},
{
"block_id_flag": 2,
"validator_address": "D436BB0B9DD430C2AE98E7D3CA651402DFD645D8",
"timestamp": "2023-07-05T20:54:14.892534239Z",
"signature": "BZCAcuYladsBblGZZ1pqk4o16yyrMfvlowZPG67Yx6zaVSyHuxCOMRBAlTNAhms/pn734QycZr79PjFLSgC9DQ=="
},
{
"block_id_flag": 2,
"validator_address": "762CBA617226A799D898F134DD12661C7F1129EB",
"timestamp": "2023-07-05T20:54:14.892534239Z",
"signature": "DPP4ekTvsH3/8UEhiUCU1+89kntsz7LnhG0gLHk0+kkKNgp+XXESLwDgRoHbuRnaYALPfbmgaq8LplJfZ6N6Ag=="
},
{
"block_id_flag": 2,
"validator_address": "DB792648B6EC5AA758F1C7D041E6CA4FBA1DE45A",
"timestamp": "2023-07-05T20:54:14.892534239Z",
"signature": "cF6ll0raSgKYh9tigo4HVLWjs6JymmiuSunThA7bWFAeRcjoYXj3+7cz3iuMOoGP5cSxeYJF7TijJ9ujHv7WCg=="
}
]
},
"validator_set": {
"validators": [
{
"address": "81A24EE534DEFE1557A4C7C437E8E8FBC2F834E8",
"pub_key": {
"type": "tendermint/PubKeyEd25519",
"value": "3iWuyTWxD2V7Q/qX5ajU5SO9sPmXJgXwsGTv97FwSLo="
},
"voting_power": "100010",
"proposer_priority": "0"
},
{
"address": "D436BB0B9DD430C2AE98E7D3CA651402DFD645D8",
"pub_key": {
"type": "tendermint/PubKeyEd25519",
"value": "jeatGlaaIj57sNreGUq7lIciEhDh+oFUv2VKEP5hWKY="
},
"voting_power": "100010",
"proposer_priority": "0"
},
{
"address": "762CBA617226A799D898F134DD12661C7F1129EB",
"pub_key": {
"type": "tendermint/PubKeyEd25519",
"value": "6bdjjKHELaN9colwYy/ad+xh3MUgOVq106ZFucK46LE="
},
"voting_power": "10",
"proposer_priority": "0"
},
{
"address": "DB792648B6EC5AA758F1C7D041E6CA4FBA1DE45A",
"pub_key": {
"type": "tendermint/PubKeyEd25519",
"value": "vWBFLn8FayIkgQXn/SmJYTcdoNkzLvZfqBaRv1Gy5QU="
},
"voting_power": "1",
"proposer_priority": "0"
}
],
"proposer": {
"address": "81A24EE534DEFE1557A4C7C437E8E8FBC2F834E8",
"pub_key": {
"type": "tendermint/PubKeyEd25519",
"value": "3iWuyTWxD2V7Q/qX5ajU5SO9sPmXJgXwsGTv97FwSLo="
},
"voting_power": "100010",
"proposer_priority": "0"
},
"total_voting_power": "200031"
}
}
177 changes: 177 additions & 0 deletions src/fixtures/12000/signed_block.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,177 @@
{
"header": {
"version": {
"block": "11",
"app": "1"
},
"chain_id": "mocha-3",
"height": "12000",
"time": "2023-07-06T01:04:12.917405868Z",
"last_block_id": {
"hash": "ACF633A4EF045B55EB0BC14163685179A5DD3D96D2EB0FBCB5FCF927F3B228D0",
"parts": {
"total": 1,
"hash": "09F7691B98F013C3AA0B8C6BB4FBB3AD8D87F5D45FD6E4C71F374FBD9FF88C59"
}
},
"last_commit_hash": "EF9C26754ED01EB6EE00E8F6D3EC607FEB8A9B6C62C72DD7AB25B28788468957",
"data_hash": "3D96B7D238E7E0456F6AF8E7CDF0A67BD6CF9C2089ECB559C659DCAA1F880353",
"validators_hash": "9F93BDDD1C5146C012BD813690EBE8DE664B717DA2909626336778B482A3B252",
"next_validators_hash": "9F93BDDD1C5146C012BD813690EBE8DE664B717DA2909626336778B482A3B252",
"consensus_hash": "C0B6A634B72AE9687EA53B6D277A73ABA1386BA3CFC6D0F26963602F7F6FFCD6",
"app_hash": "AF878F332FB817F73CD330ABC71497056544375FC5F5C81BF7FBEF3CBF9C460E",
"last_results_hash": "E3B0C44298FC1C149AFBF4C8996FB92427AE41E4649B934CA495991B7852B855",
"evidence_hash": "E3B0C44298FC1C149AFBF4C8996FB92427AE41E4649B934CA495991B7852B855",
"proposer_address": "D436BB0B9DD430C2AE98E7D3CA651402DFD645D8"
},
"data": {
"txs": null
},
"commit": {
"height": "12000",
"round": 0,
"block_id": {
"hash": "422727EC819F17268A2C610896CDC14D43E0B0EA461FF045A33E4328AA6A971D",
"parts": {
"total": 1,
"hash": "2B53466FF044706BCC4D73E5F329CB73BDCB4F346AC15E76F31871CFC8E6CB87"
}
},
"signatures": [
{
"block_id_flag": 2,
"validator_address": "81A24EE534DEFE1557A4C7C437E8E8FBC2F834E8",
"timestamp": "2023-07-06T01:04:26.821547433Z",
"signature": "XdmDv+5LekPvFQP7dzMY+tMwj5w2PRcdLqKTFVqWiPCN5hjMj0DFkXW65xqxA4PcstwoZKeQA3YboKprWFBsDg=="
},
{
"block_id_flag": 2,
"validator_address": "D436BB0B9DD430C2AE98E7D3CA651402DFD645D8",
"timestamp": "2023-07-06T01:04:26.803976588Z",
"signature": "WenPxlM7am78cknk2xld1yBv8r4V6rH53h/FnmPc1VQcS8zefatK5ECVCk5QeSBVWZhgv/iRYfsk8/hhItH3Dw=="
},
{
"block_id_flag": 2,
"validator_address": "762CBA617226A799D898F134DD12661C7F1129EB",
"timestamp": "2023-07-06T01:04:26.920882313Z",
"signature": "3ZkvOVqxjOROmuCnwv9s9P5edt/WRu3dmlAtORhirc3ztdr140QkoNQoEMm8/wx250Go50KdhRb6D1GonXS/Dg=="
},
{
"block_id_flag": 2,
"validator_address": "6CFE40213A360DC04C4E960803C9E85DAFF9BC4F",
"timestamp": "2023-07-06T01:04:26.80051773Z",
"signature": "MSK+VNZjW5KdWh0MstUPChCpMKLiS1cuyqod12IxXEm1l3Wl8A5EC9C2mABBz4MVFxKfbtl8wdzkEvXV7DvfAQ=="
},
{
"block_id_flag": 2,
"validator_address": "110F48CDE021C66B9B00441D0A6B24D358608607",
"timestamp": "2023-07-06T01:04:26.951918887Z",
"signature": "KVNv/tksTHFxvhYVrrMZQkilTue6vW9aCfBQJKiLYsFNl/W4Ol+OunCZlWvQO7WLClJF5NNxO6cCMXazaCJ9Dg=="
},
{
"block_id_flag": 1,
"validator_address": "",
"timestamp": "1970-01-01T00:00:00Z",
"signature": ""
},
{
"block_id_flag": 2,
"validator_address": "EE927F115AD4FD4BC131CA311D332ADDAC62CCAC",
"timestamp": "2023-07-06T01:04:26.840958664Z",
"signature": "cSAmQ8R/U4tVCRX3LOkhmwYXZV62mIcLg1JHIxyMgNAPMhTLuG0qbhg2/EYVEZCcxKqpo2VFVa2EApiFPWN+Bw=="
},
{
"block_id_flag": 2,
"validator_address": "62D008BE0CA3627CFEA58260D744B38AE46E921F",
"timestamp": "2023-07-06T01:04:26.9185206Z",
"signature": "aGbz2KcGsj+Uud5OSvWpPxXhrNnDB8ualIR9SDJSuLlkY+TapDq23Ix7P/+gxSxs2jJxWTUmhfu29ZiACVbjDA=="
}
]
},
"validator_set": {
"validators": [
{
"address": "81A24EE534DEFE1557A4C7C437E8E8FBC2F834E8",
"pub_key": {
"type": "tendermint/PubKeyEd25519",
"value": "3iWuyTWxD2V7Q/qX5ajU5SO9sPmXJgXwsGTv97FwSLo="
},
"power": "100010",
"name": null
},
{
"address": "D436BB0B9DD430C2AE98E7D3CA651402DFD645D8",
"pub_key": {
"type": "tendermint/PubKeyEd25519",
"value": "jeatGlaaIj57sNreGUq7lIciEhDh+oFUv2VKEP5hWKY="
},
"power": "100010",
"name": null
},
{
"address": "762CBA617226A799D898F134DD12661C7F1129EB",
"pub_key": {
"type": "tendermint/PubKeyEd25519",
"value": "6bdjjKHELaN9colwYy/ad+xh3MUgOVq106ZFucK46LE="
},
"power": "100000",
"name": null
},
{
"address": "6CFE40213A360DC04C4E960803C9E85DAFF9BC4F",
"pub_key": {
"type": "tendermint/PubKeyEd25519",
"value": "AZNamtmqyMW3W2aznvSJT6TheVXrNB9ihuVNbh0vpfA="
},
"power": "702",
"name": null
},
{
"address": "110F48CDE021C66B9B00441D0A6B24D358608607",
"pub_key": {
"type": "tendermint/PubKeyEd25519",
"value": "eXFJj8jJ0TwvoB1sqiDIIFy4UywE95w2YDLPaaVHxrk="
},
"power": "328",
"name": null
},
{
"address": "DB792648B6EC5AA758F1C7D041E6CA4FBA1DE45A",
"pub_key": {
"type": "tendermint/PubKeyEd25519",
"value": "vWBFLn8FayIkgQXn/SmJYTcdoNkzLvZfqBaRv1Gy5QU="
},
"power": "301",
"name": null
},
{
"address": "EE927F115AD4FD4BC131CA311D332ADDAC62CCAC",
"pub_key": {
"type": "tendermint/PubKeyEd25519",
"value": "SfFXATPCbIeRUsb9RP+BfdYOH0v7H2aGbPGx1HlR1I0="
},
"power": "50",
"name": null
},
{
"address": "62D008BE0CA3627CFEA58260D744B38AE46E921F",
"pub_key": {
"type": "tendermint/PubKeyEd25519",
"value": "Lan+2S2twOYqQ/Dc9VDgc9ixyeRjGldLTbiWJWbINe8="
},
"power": "1",
"name": null
}
],
"proposer": {
"address": "D436BB0B9DD430C2AE98E7D3CA651402DFD645D8",
"pub_key": {
"type": "tendermint/PubKeyEd25519",
"value": "jeatGlaaIj57sNreGUq7lIciEhDh+oFUv2VKEP5hWKY="
},
"power": "100010",
"name": null
},
"total_voting_power": "301402"
}
}
72 changes: 72 additions & 0 deletions src/fixtures/5/signed_block.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
{
"header": {
"version": {
"block": "11",
"app": "1"
},
"chain_id": "mocha-3",
"height": "5",
"time": "2023-07-03T23:05:12.172148532Z",
"last_block_id": {
"hash": "D92C72F8205694ADD968173823D1AD3E88FCEE4893891D1C267C8AC9C6A2EDA2",
"parts": {
"total": 1,
"hash": "06A057FD0E0015F6FF324D03FF12E6A1A4BEA57A0841016CF20E884C3CE39458"
}
},
"last_commit_hash": "A7EA6CC2C2A35EDD64A8442E82C60A8DE53686BA2924AEFB6859259F32750B26",
"data_hash": "3D96B7D238E7E0456F6AF8E7CDF0A67BD6CF9C2089ECB559C659DCAA1F880353",
"validators_hash": "AB173BDBB0A0446DB3649886773BCF5B8106424E4AA24650141342E2DE34DA8C",
"next_validators_hash": "AB173BDBB0A0446DB3649886773BCF5B8106424E4AA24650141342E2DE34DA8C",
"consensus_hash": "C0B6A634B72AE9687EA53B6D277A73ABA1386BA3CFC6D0F26963602F7F6FFCD6",
"app_hash": "A9AE9C4F966CE06E750532A83957E4D1EEBC4098F498B427CB744E273AE79FAE",
"last_results_hash": "E3B0C44298FC1C149AFBF4C8996FB92427AE41E4649B934CA495991B7852B855",
"evidence_hash": "E3B0C44298FC1C149AFBF4C8996FB92427AE41E4649B934CA495991B7852B855",
"proposer_address": "81A24EE534DEFE1557A4C7C437E8E8FBC2F834E8"
},
"data": {
"txs": null
},
"commit": {
"height": "5",
"round": 0,
"block_id": {
"hash": "01C48756BAEDAD42C1D2A0F9E91FF58E5525BB721E80FFAEC27A4EADBD9E42EE",
"parts": {
"total": 1,
"hash": "2BDAEE1115B432C95BA2D2B079FF761C3588F67D1C779ABA1519A0E3D0DC69F2"
}
},
"signatures": [
{
"block_id_flag": 2,
"validator_address": "81A24EE534DEFE1557A4C7C437E8E8FBC2F834E8",
"timestamp": "2023-07-03T23:05:24.182283106Z",
"signature": "AarwYaRE7h/zZFOLSOovAIHfci6RpcJar4u/LZv/SOOxpGADpNfBBbs714g5zEEwQtU8saLDAxGCbCfDmx+KDw=="
}
]
},
"validator_set": {
"validators": [
{
"address": "81A24EE534DEFE1557A4C7C437E8E8FBC2F834E8",
"pub_key": {
"type": "tendermint/PubKeyEd25519",
"value": "3iWuyTWxD2V7Q/qX5ajU5SO9sPmXJgXwsGTv97FwSLo="
},
"power": "10",
"name": null
}
],
"proposer": {
"address": "81A24EE534DEFE1557A4C7C437E8E8FBC2F834E8",
"pub_key": {
"type": "tendermint/PubKeyEd25519",
"value": "3iWuyTWxD2V7Q/qX5ajU5SO9sPmXJgXwsGTv97FwSLo="
},
"power": "10",
"name": null
},
"total_voting_power": "10"
}
}
Loading