Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
d9aea70
Removed unused inclusion proof
tannaurus Apr 10, 2025
cd8c8f8
Created proofgen: a binary that writes the inclusion and consistency …
tannaurus Apr 14, 2025
7475a83
Tests running with json
tannaurus Apr 15, 2025
c0bd049
Refactored proofgen, restored original test coverage
tannaurus Apr 15, 2025
e8c3359
Moved directory creation into createDirectory
tannaurus Apr 15, 2025
6b7faec
Updated license, cleaned up test file.
tannaurus Apr 15, 2025
5719dd2
Restored tests: L343 & L344
tannaurus Apr 15, 2025
1b5fa62
Bug fix: no longer re-writting static inclusion test data
tannaurus Apr 15, 2025
428c4c0
Supporting improvements
mhutchinson Apr 16, 2025
7f95861
Tidy how files are read
mhutchinson Apr 16, 2025
2a59128
Various error handling improvements: inlining func call, replacing pa…
tannaurus Apr 16, 2025
73a0db1
Renamed leafIndex to LeafIdx
tannaurus Apr 16, 2025
6d55198
Replace createDirectory with inline call to os.MkdirAll
tannaurus Apr 16, 2025
4858c19
Replaced variable 'hasher' with rfc6962.DefaultHasher
tannaurus Apr 16, 2025
be4156f
'corrupt' -> 'invalid'
tannaurus Apr 16, 2025
9657fa2
Restored original license year
tannaurus Apr 16, 2025
536bb55
Updated 'extend' to no longer pre-allocate
tannaurus Apr 16, 2025
65362ac
Using MarshalIndent to format json output
tannaurus Apr 16, 2025
42b762b
Reduced size of variables: 'directory' -> 'dir', etc.
tannaurus Apr 16, 2025
eb6f9b7
Replace specicial characters in filenames with shell friendly replace…
tannaurus Apr 16, 2025
ac550d5
Fixed golangci-lint errors
tannaurus Apr 17, 2025
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
480 changes: 480 additions & 0 deletions cmd/proofgen/main.go

Large diffs are not rendered by default.

432 changes: 91 additions & 341 deletions proof/verify_test.go

Large diffs are not rendered by default.

20 changes: 19 additions & 1 deletion scripts/presubmit.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ check_cmd() {
}

usage() {
echo "$0 [--coverage] [--fix] [--no-mod-tidy] [--no-build] [--no-linters]"
echo "$0 [--coverage] [--fix] [--no-mod-tidy] [--no-build] [--no-linters] [--no-generate] [--empty-diff]"
}

main() {
Expand All @@ -35,6 +35,8 @@ main() {
local run_mod_tidy=1
local run_build=1
local run_lint=1
local run_generate=1
local empty_diff=0
while [[ $# -gt 0 ]]; do
case "$1" in
--coverage)
Expand All @@ -56,6 +58,12 @@ main() {
--no-linters)
run_lint=0
;;
--no-generate)
run_generate=0
;;
--empty-diff)
empty_diff=1
;;
*)
usage
exit 1
Expand Down Expand Up @@ -110,6 +118,16 @@ main() {
echo 'checking license headers'
./scripts/check_license.sh ${go_srcs}
fi

if [[ "${run_generate}" -eq 1 ]]; then
echo 'running go generate'
go run ./cmd/proofgen
fi

if [[ "${empty_diff}" -eq 1 ]]; then
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a great addition. Thanks @mhutchinson !

echo 'checking git diff is empty'
git diff --exit-code
fi
}

main "$@"
9 changes: 9 additions & 0 deletions testdata/consistency/0/happy-path.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"size1": 1,
"size2": 1,
"root1": "bjQLnP+zepicpUTmu3gKLHiQHT+zNzh2hRGjBhevoB0=",
"root2": "bjQLnP+zepicpUTmu3gKLHiQHT+zNzh2hRGjBhevoB0=",
"proof": null,
"desc": "happy path",
"wantErr": false
}
9 changes: 9 additions & 0 deletions testdata/consistency/1/empty-proof.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"size1": 1,
"size2": 8,
"root1": "bjQLnP+zepicpUTmu3gKLHiQHT+zNzh2hRGjBhevoB0=",
"root2": "XcnaeacGWamtVZy3Ad7ZoqudgjqtL0lgz+Nw7/RgQyg=",
"proof": [],
"desc": "empty proof",
"wantErr": true
}
13 changes: 13 additions & 0 deletions testdata/consistency/1/happy-path.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"size1": 1,
"size2": 8,
"root1": "bjQLnP+zepicpUTmu3gKLHiQHT+zNzh2hRGjBhevoB0=",
"root2": "XcnaeacGWamtVZy3Ad7ZoqudgjqtL0lgz+Nw7/RgQyg=",
"proof": [
"lqKW0iTyhcZ77pPDD4owkVfw2qNdxbh+QQt4YwoJz8c=",
"Xwg/ChozygdqlSeYMlgNs+DvRYS9/x9UyKNg9Q3jAx4=",
"a0eq8p7jwq+a+Im8H7klTavTEXfxYjLdaqsDXKOb9uQ="
],
"desc": "happy path",
"wantErr": false
}
13 changes: 13 additions & 0 deletions testdata/consistency/1/modified-proof@0-bit-@4.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"size1": 1,
"size2": 8,
"root1": "bjQLnP+zepicpUTmu3gKLHiQHT+zNzh2hRGjBhevoB0=",
"root2": "XcnaeacGWamtVZy3Ad7ZoqudgjqtL0lgz+Nw7/RgQyg=",
"proof": [
"hqKW0iTyhcZ77pPDD4owkVfw2qNdxbh+QQt4YwoJz8c=",
"Xwg/ChozygdqlSeYMlgNs+DvRYS9/x9UyKNg9Q3jAx4=",
"a0eq8p7jwq+a+Im8H7klTavTEXfxYjLdaqsDXKOb9uQ="
],
"desc": "modified proof@0 bit @4",
"wantErr": true
}
13 changes: 13 additions & 0 deletions testdata/consistency/1/modified-proof@1-bit-@4.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"size1": 1,
"size2": 8,
"root1": "bjQLnP+zepicpUTmu3gKLHiQHT+zNzh2hRGjBhevoB0=",
"root2": "XcnaeacGWamtVZy3Ad7ZoqudgjqtL0lgz+Nw7/RgQyg=",
"proof": [
"lqKW0iTyhcZ77pPDD4owkVfw2qNdxbh+QQt4YwoJz8c=",
"Twg/ChozygdqlSeYMlgNs+DvRYS9/x9UyKNg9Q3jAx4=",
"a0eq8p7jwq+a+Im8H7klTavTEXfxYjLdaqsDXKOb9uQ="
],
"desc": "modified proof@1 bit @4",
"wantErr": true
}
13 changes: 13 additions & 0 deletions testdata/consistency/1/modified-proof@2-bit-@4.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"size1": 1,
"size2": 8,
"root1": "bjQLnP+zepicpUTmu3gKLHiQHT+zNzh2hRGjBhevoB0=",
"root2": "XcnaeacGWamtVZy3Ad7ZoqudgjqtL0lgz+Nw7/RgQyg=",
"proof": [
"lqKW0iTyhcZ77pPDD4owkVfw2qNdxbh+QQt4YwoJz8c=",
"Xwg/ChozygdqlSeYMlgNs+DvRYS9/x9UyKNg9Q3jAx4=",
"e0eq8p7jwq+a+Im8H7klTavTEXfxYjLdaqsDXKOb9uQ="
],
"desc": "modified proof@2 bit @4",
"wantErr": true
}
14 changes: 14 additions & 0 deletions testdata/consistency/1/preceding-garbage.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"size1": 1,
"size2": 8,
"root1": "bjQLnP+zepicpUTmu3gKLHiQHT+zNzh2hRGjBhevoB0=",
"root2": "XcnaeacGWamtVZy3Ad7ZoqudgjqtL0lgz+Nw7/RgQyg=",
"proof": [
"",
"lqKW0iTyhcZ77pPDD4owkVfw2qNdxbh+QQt4YwoJz8c=",
"Xwg/ChozygdqlSeYMlgNs+DvRYS9/x9UyKNg9Q3jAx4=",
"a0eq8p7jwq+a+Im8H7klTavTEXfxYjLdaqsDXKOb9uQ="
],
"desc": "preceding garbage",
"wantErr": true
}
14 changes: 14 additions & 0 deletions testdata/consistency/1/preceding-proof-@0.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"size1": 1,
"size2": 8,
"root1": "bjQLnP+zepicpUTmu3gKLHiQHT+zNzh2hRGjBhevoB0=",
"root2": "XcnaeacGWamtVZy3Ad7ZoqudgjqtL0lgz+Nw7/RgQyg=",
"proof": [
"lqKW0iTyhcZ77pPDD4owkVfw2qNdxbh+QQt4YwoJz8c=",
"lqKW0iTyhcZ77pPDD4owkVfw2qNdxbh+QQt4YwoJz8c=",
"Xwg/ChozygdqlSeYMlgNs+DvRYS9/x9UyKNg9Q3jAx4=",
"a0eq8p7jwq+a+Im8H7klTavTEXfxYjLdaqsDXKOb9uQ="
],
"desc": "preceding proof @0",
"wantErr": true
}
14 changes: 14 additions & 0 deletions testdata/consistency/1/preceding-root1.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"size1": 1,
"size2": 8,
"root1": "bjQLnP+zepicpUTmu3gKLHiQHT+zNzh2hRGjBhevoB0=",
"root2": "XcnaeacGWamtVZy3Ad7ZoqudgjqtL0lgz+Nw7/RgQyg=",
"proof": [
"bjQLnP+zepicpUTmu3gKLHiQHT+zNzh2hRGjBhevoB0=",
"lqKW0iTyhcZ77pPDD4owkVfw2qNdxbh+QQt4YwoJz8c=",
"Xwg/ChozygdqlSeYMlgNs+DvRYS9/x9UyKNg9Q3jAx4=",
"a0eq8p7jwq+a+Im8H7klTavTEXfxYjLdaqsDXKOb9uQ="
],
"desc": "preceding root1",
"wantErr": true
}
14 changes: 14 additions & 0 deletions testdata/consistency/1/preceding-root2.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"size1": 1,
"size2": 8,
"root1": "bjQLnP+zepicpUTmu3gKLHiQHT+zNzh2hRGjBhevoB0=",
"root2": "XcnaeacGWamtVZy3Ad7ZoqudgjqtL0lgz+Nw7/RgQyg=",
"proof": [
"XcnaeacGWamtVZy3Ad7ZoqudgjqtL0lgz+Nw7/RgQyg=",
"lqKW0iTyhcZ77pPDD4owkVfw2qNdxbh+QQt4YwoJz8c=",
"Xwg/ChozygdqlSeYMlgNs+DvRYS9/x9UyKNg9Q3jAx4=",
"a0eq8p7jwq+a+Im8H7klTavTEXfxYjLdaqsDXKOb9uQ="
],
"desc": "preceding root2",
"wantErr": true
}
13 changes: 13 additions & 0 deletions testdata/consistency/1/size1-XOR-@2.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"size1": 3,
"size2": 8,
"root1": "bjQLnP+zepicpUTmu3gKLHiQHT+zNzh2hRGjBhevoB0=",
"root2": "XcnaeacGWamtVZy3Ad7ZoqudgjqtL0lgz+Nw7/RgQyg=",
"proof": [
"lqKW0iTyhcZ77pPDD4owkVfw2qNdxbh+QQt4YwoJz8c=",
"Xwg/ChozygdqlSeYMlgNs+DvRYS9/x9UyKNg9Q3jAx4=",
"a0eq8p7jwq+a+Im8H7klTavTEXfxYjLdaqsDXKOb9uQ="
],
"desc": "size1 XOR @2",
"wantErr": true
}
13 changes: 13 additions & 0 deletions testdata/consistency/1/size1-plus-@1.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"size1": 2,
"size2": 8,
"root1": "bjQLnP+zepicpUTmu3gKLHiQHT+zNzh2hRGjBhevoB0=",
"root2": "XcnaeacGWamtVZy3Ad7ZoqudgjqtL0lgz+Nw7/RgQyg=",
"proof": [
"lqKW0iTyhcZ77pPDD4owkVfw2qNdxbh+QQt4YwoJz8c=",
"Xwg/ChozygdqlSeYMlgNs+DvRYS9/x9UyKNg9Q3jAx4=",
"a0eq8p7jwq+a+Im8H7klTavTEXfxYjLdaqsDXKOb9uQ="
],
"desc": "size1 plus @1",
"wantErr": true
}
13 changes: 13 additions & 0 deletions testdata/consistency/1/size1-sub-@1.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"size1": 0,
"size2": 8,
"root1": "bjQLnP+zepicpUTmu3gKLHiQHT+zNzh2hRGjBhevoB0=",
"root2": "XcnaeacGWamtVZy3Ad7ZoqudgjqtL0lgz+Nw7/RgQyg=",
"proof": [
"lqKW0iTyhcZ77pPDD4owkVfw2qNdxbh+QQt4YwoJz8c=",
"Xwg/ChozygdqlSeYMlgNs+DvRYS9/x9UyKNg9Q3jAx4=",
"a0eq8p7jwq+a+Im8H7klTavTEXfxYjLdaqsDXKOb9uQ="
],
"desc": "size1 sub @1",
"wantErr": true
}
13 changes: 13 additions & 0 deletions testdata/consistency/1/size2-div-@2.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"size1": 1,
"size2": 4,
"root1": "bjQLnP+zepicpUTmu3gKLHiQHT+zNzh2hRGjBhevoB0=",
"root2": "XcnaeacGWamtVZy3Ad7ZoqudgjqtL0lgz+Nw7/RgQyg=",
"proof": [
"lqKW0iTyhcZ77pPDD4owkVfw2qNdxbh+QQt4YwoJz8c=",
"Xwg/ChozygdqlSeYMlgNs+DvRYS9/x9UyKNg9Q3jAx4=",
"a0eq8p7jwq+a+Im8H7klTavTEXfxYjLdaqsDXKOb9uQ="
],
"desc": "size2 div @2",
"wantErr": true
}
13 changes: 13 additions & 0 deletions testdata/consistency/1/size2-mul-@2.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"size1": 1,
"size2": 16,
"root1": "bjQLnP+zepicpUTmu3gKLHiQHT+zNzh2hRGjBhevoB0=",
"root2": "XcnaeacGWamtVZy3Ad7ZoqudgjqtL0lgz+Nw7/RgQyg=",
"proof": [
"lqKW0iTyhcZ77pPDD4owkVfw2qNdxbh+QQt4YwoJz8c=",
"Xwg/ChozygdqlSeYMlgNs+DvRYS9/x9UyKNg9Q3jAx4=",
"a0eq8p7jwq+a+Im8H7klTavTEXfxYjLdaqsDXKOb9uQ="
],
"desc": "size2 mul @2",
"wantErr": true
}
13 changes: 13 additions & 0 deletions testdata/consistency/1/swapped-roots.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"size1": 1,
"size2": 8,
"root1": "XcnaeacGWamtVZy3Ad7ZoqudgjqtL0lgz+Nw7/RgQyg=",
"root2": "bjQLnP+zepicpUTmu3gKLHiQHT+zNzh2hRGjBhevoB0=",
"proof": [
"lqKW0iTyhcZ77pPDD4owkVfw2qNdxbh+QQt4YwoJz8c=",
"Xwg/ChozygdqlSeYMlgNs+DvRYS9/x9UyKNg9Q3jAx4=",
"a0eq8p7jwq+a+Im8H7klTavTEXfxYjLdaqsDXKOb9uQ="
],
"desc": "swapped roots",
"wantErr": true
}
14 changes: 14 additions & 0 deletions testdata/consistency/1/trailing-garbage.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"size1": 1,
"size2": 8,
"root1": "bjQLnP+zepicpUTmu3gKLHiQHT+zNzh2hRGjBhevoB0=",
"root2": "XcnaeacGWamtVZy3Ad7ZoqudgjqtL0lgz+Nw7/RgQyg=",
"proof": [
"lqKW0iTyhcZ77pPDD4owkVfw2qNdxbh+QQt4YwoJz8c=",
"Xwg/ChozygdqlSeYMlgNs+DvRYS9/x9UyKNg9Q3jAx4=",
"a0eq8p7jwq+a+Im8H7klTavTEXfxYjLdaqsDXKOb9uQ=",
""
],
"desc": "trailing garbage",
"wantErr": true
}
14 changes: 14 additions & 0 deletions testdata/consistency/1/trailing-root1.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"size1": 1,
"size2": 8,
"root1": "bjQLnP+zepicpUTmu3gKLHiQHT+zNzh2hRGjBhevoB0=",
"root2": "XcnaeacGWamtVZy3Ad7ZoqudgjqtL0lgz+Nw7/RgQyg=",
"proof": [
"lqKW0iTyhcZ77pPDD4owkVfw2qNdxbh+QQt4YwoJz8c=",
"Xwg/ChozygdqlSeYMlgNs+DvRYS9/x9UyKNg9Q3jAx4=",
"a0eq8p7jwq+a+Im8H7klTavTEXfxYjLdaqsDXKOb9uQ=",
"bjQLnP+zepicpUTmu3gKLHiQHT+zNzh2hRGjBhevoB0="
],
"desc": "trailing root1",
"wantErr": true
}
14 changes: 14 additions & 0 deletions testdata/consistency/1/trailing-root2.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"size1": 1,
"size2": 8,
"root1": "bjQLnP+zepicpUTmu3gKLHiQHT+zNzh2hRGjBhevoB0=",
"root2": "XcnaeacGWamtVZy3Ad7ZoqudgjqtL0lgz+Nw7/RgQyg=",
"proof": [
"lqKW0iTyhcZ77pPDD4owkVfw2qNdxbh+QQt4YwoJz8c=",
"Xwg/ChozygdqlSeYMlgNs+DvRYS9/x9UyKNg9Q3jAx4=",
"a0eq8p7jwq+a+Im8H7klTavTEXfxYjLdaqsDXKOb9uQ=",
"XcnaeacGWamtVZy3Ad7ZoqudgjqtL0lgz+Nw7/RgQyg="
],
"desc": "trailing root2",
"wantErr": true
}
12 changes: 12 additions & 0 deletions testdata/consistency/1/truncated-proof.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"size1": 1,
"size2": 8,
"root1": "bjQLnP+zepicpUTmu3gKLHiQHT+zNzh2hRGjBhevoB0=",
"root2": "XcnaeacGWamtVZy3Ad7ZoqudgjqtL0lgz+Nw7/RgQyg=",
"proof": [
"lqKW0iTyhcZ77pPDD4owkVfw2qNdxbh+QQt4YwoJz8c=",
"Xwg/ChozygdqlSeYMlgNs+DvRYS9/x9UyKNg9Q3jAx4="
],
"desc": "truncated proof",
"wantErr": true
}
13 changes: 13 additions & 0 deletions testdata/consistency/1/wrong-root1.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"size1": 1,
"size2": 8,
"root1": "V3JvbmdSb290",
"root2": "XcnaeacGWamtVZy3Ad7ZoqudgjqtL0lgz+Nw7/RgQyg=",
"proof": [
"lqKW0iTyhcZ77pPDD4owkVfw2qNdxbh+QQt4YwoJz8c=",
"Xwg/ChozygdqlSeYMlgNs+DvRYS9/x9UyKNg9Q3jAx4=",
"a0eq8p7jwq+a+Im8H7klTavTEXfxYjLdaqsDXKOb9uQ="
],
"desc": "wrong root1",
"wantErr": true
}
13 changes: 13 additions & 0 deletions testdata/consistency/1/wrong-root2.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"size1": 1,
"size2": 8,
"root1": "bjQLnP+zepicpUTmu3gKLHiQHT+zNzh2hRGjBhevoB0=",
"root2": "V3JvbmdSb290",
"proof": [
"lqKW0iTyhcZ77pPDD4owkVfw2qNdxbh+QQt4YwoJz8c=",
"Xwg/ChozygdqlSeYMlgNs+DvRYS9/x9UyKNg9Q3jAx4=",
"a0eq8p7jwq+a+Im8H7klTavTEXfxYjLdaqsDXKOb9uQ="
],
"desc": "wrong root2",
"wantErr": true
}
9 changes: 9 additions & 0 deletions testdata/consistency/2/empty-proof.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"size1": 6,
"size2": 8,
"root1": "duZ9rbzfHhDht03cYIq9L5jfsW+851J3tSMqEn8gh+8=",
"root2": "XcnaeacGWamtVZy3Ad7ZoqudgjqtL0lgz+Nw7/RgQyg=",
"proof": [],
"desc": "empty proof",
"wantErr": true
}
Loading
Loading