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

primitives: Add inclusion proof funcs. #2827

Merged
merged 2 commits into from
Dec 5, 2021

Conversation

davecgh
Copy link
Member

@davecgh davecgh commented Nov 20, 2021

This requires #2826.

This adds new functions for generating and verifying inclusion proofs along with associated tests. The functions are direct ports of the functions of the same names from blockchain/standalone.

Specifically, the following functions are updated and added along with their associated tests and benchmarks:

  • GenerateInclusionProof (equiv to standalone.GenerateInclusionProof)
  • VerifyInclusionProof (equiv to standalone.VerifyInclusionProof)

It also updates the documentation.

BenchmarkGenerateInclusionProof
-------------------------------
64_leaves     31101     38577 ns/op    2240 B/op   2 allocs/op
128_leaves    15512     77140 ns/op    4320 B/op   2 allocs/op
256_leaves     7999    155127 ns/op    8448 B/op   2 allocs/op
2048_leaves     975   1237867 ns/op   65888 B/op   2 allocs/op

BenchmarkVerifyInclusionProof
-----------------------------
64_leaves     333319   3999 ns/op   0 B/op   0 allocs/op
128_leaves    287670   4187 ns/op   0 B/op   0 allocs/op
256_leaves    249007   4841 ns/op   0 B/op   0 allocs/op
2048_leaves   181994   6683 ns/op   0 B/op   0 allocs/op

This is work towards #2786.

internal/staging/primitives/inclusionproof.go Outdated Show resolved Hide resolved
internal/staging/primitives/inclusionproof.go Outdated Show resolved Hide resolved
internal/staging/primitives/inclusionproof.go Outdated Show resolved Hide resolved
Copy link
Member

@JoeGruffins JoeGruffins left a comment

Choose a reason for hiding this comment

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

benchmarks
goos: linux
goarch: amd64
pkg: github.com/decred/dcrd/internal/staging/primitives
cpu: AMD Ryzen 9 3900XT 12-Core Processor           
BenchmarkGenerateInclusionProof/64_leaves-24               39133             35708 ns/op            2240 B/op          2 allocs/op
BenchmarkGenerateInclusionProof/128_leaves-24              16256             70110 ns/op            4320 B/op          2 allocs/op
BenchmarkGenerateInclusionProof/256_leaves-24               8134            159816 ns/op            8448 B/op          2 allocs/op
BenchmarkGenerateInclusionProof/2048_leaves-24               996           1097113 ns/op           65888 B/op          2 allocs/op
BenchmarkVerifyInclusionProof/64_leaves-24                467757              2467 ns/op               0 B/op          0 allocs/op
BenchmarkVerifyInclusionProof/128_leaves-24               404984              2843 ns/op               0 B/op          0 allocs/op
BenchmarkVerifyInclusionProof/256_leaves-24               360238              3282 ns/op               0 B/op          0 allocs/op
BenchmarkVerifyInclusionProof/2048_leaves-24              250671              4594 ns/op               0 B/op          0 allocs/op

internal/staging/primitives/inclusionproof.go Show resolved Hide resolved
Copy link
Member

@rstaudt2 rstaudt2 left a comment

Choose a reason for hiding this comment

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

Looks good, I just had a couple of minor comments related to the tests.

@davecgh davecgh force-pushed the primitives_inclusion_proofs branch 2 times, most recently from bcf5fca to 69a0a59 Compare December 4, 2021 19:13
This adds new functions for generating and verifying inclusion proofs
along with associated tests.

The functions are direct ports of the functions of the same names from
blockchain/standalone.

It also updates the documentation.
BenchmarkGenerateInclusionProof
-------------------------------
64_leaves     31101     38577 ns/op    2240 B/op   2 allocs/op
128_leaves    15512     77140 ns/op    4320 B/op   2 allocs/op
256_leaves     7999    155127 ns/op    8448 B/op   2 allocs/op
2048_leaves     975   1237867 ns/op   65888 B/op   2 allocs/op

BenchmarkVerifyInclusionProof
-----------------------------
64_leaves     333319   3999 ns/op   0 B/op   0 allocs/op
128_leaves    287670   4187 ns/op   0 B/op   0 allocs/op
256_leaves    249007   4841 ns/op   0 B/op   0 allocs/op
2048_leaves   181994   6683 ns/op   0 B/op   0 allocs/op
@davecgh davecgh merged commit 17ded21 into decred:master Dec 5, 2021
@davecgh davecgh deleted the primitives_inclusion_proofs branch December 5, 2021 00:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants