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

[crypto/ed25519] ed25519 Concurrent Batch Verification + ZIP-215 Enforcement #338

Merged
merged 10 commits into from
Aug 11, 2023

Conversation

patrick-ogrady
Copy link
Contributor

@patrick-ogrady patrick-ogrady commented Aug 8, 2023

Resolves: #337

TL;DR: single verification cost drops from 45000 ns to 27000 ns when using the new library (-40%) and 45000 ns to 8904 ns (-80%) when using batch verify.

Results:

goos: darwin
goarch: arm64
pkg: github.com/ava-labs/hypersdk/crypto
BenchmarkStdLibVerifySingle-12       	   24030	     49676 ns/op
BenchmarkOasisVerifySingle-12        	   35736	     33637 ns/op
BenchmarkOasisVerifyCache-12         	   40842	     29192 ns/op
BenchmarkOasisBatchVerify/1-12       	   24301	     49368 ns/op
BenchmarkOasisBatchVerify/4-12       	   10000	    102825 ns/op
BenchmarkOasisBatchVerify/16-12      	    3878	    313535 ns/op
BenchmarkOasisBatchVerify/64-12      	    1038	   1229892 ns/op
BenchmarkOasisBatchVerify/128-12     	     538	   2228857 ns/op
BenchmarkOasisBatchVerify/512-12     	     166	   7086516 ns/op
BenchmarkOasisBatchVerify/1024-12    	      94	  12970639 ns/op
BenchmarkOasisBatchVerify/4096-12    	      24	  48236476 ns/op
BenchmarkOasisBatchVerify/16384-12   	       6	 187775667 ns/op
BenchmarkOasisBatchVerifyCache/1-12  	   26325	     46554 ns/op
BenchmarkOasisBatchVerifyCache/4-12  	   13917	     85865 ns/op
BenchmarkOasisBatchVerifyCache/16-12 	    4866	    243184 ns/op
BenchmarkOasisBatchVerifyCache/64-12 	    1369	    869321 ns/op
BenchmarkOasisBatchVerifyCache/128-12         	     687	   1744689 ns/op
BenchmarkOasisBatchVerifyCache/512-12         	     208	   5807465 ns/op
BenchmarkOasisBatchVerifyCache/1024-12        	     100	  10393727 ns/op
BenchmarkOasisBatchVerifyCache/4096-12        	      31	  38042855 ns/op
BenchmarkOasisBatchVerifyCache/16384-12       	       7	 148778535 ns/op
PASS
ok  	github.com/ava-labs/hypersdk/crypto	97.032s

Results on single core (~same -> can still parallelize):

goos: darwin
goarch: arm64
pkg: github.com/ava-labs/hypersdk/crypto
BenchmarkStdLibVerifySingle    	   27198	     43851 ns/op
BenchmarkOasisVerifySingle     	   36319	     33057 ns/op
BenchmarkOasisVerifyCache      	   43023	     27136 ns/op
BenchmarkOasisBatchVerify/1    	   24878	     48444 ns/op
BenchmarkOasisBatchVerify/4    	   10000	    101226 ns/op
BenchmarkOasisBatchVerify/16   	    3859	    303776 ns/op
BenchmarkOasisBatchVerify/64   	    1074	   1122474 ns/op
BenchmarkOasisBatchVerify/128  	     560	   2135260 ns/op
BenchmarkOasisBatchVerify/512  	     174	   6923636 ns/op
BenchmarkOasisBatchVerify/1024 	      94	  12679955 ns/op
BenchmarkOasisBatchVerify/4096 	      25	  47537617 ns/op
BenchmarkOasisBatchVerify/16384         	       6	 187736208 ns/op
BenchmarkOasisBatchVerifyCache/1        	   28065	     42653 ns/op
BenchmarkOasisBatchVerifyCache/4        	   14504	     83176 ns/op
BenchmarkOasisBatchVerifyCache/16       	    5005	    240122 ns/op
BenchmarkOasisBatchVerifyCache/64       	    1395	    863280 ns/op
BenchmarkOasisBatchVerifyCache/128      	     712	   1699842 ns/op
BenchmarkOasisBatchVerifyCache/512      	     214	   5878363 ns/op
BenchmarkOasisBatchVerifyCache/1024     	     100	  10013806 ns/op
BenchmarkOasisBatchVerifyCache/4096     	      32	  37275258 ns/op
BenchmarkOasisBatchVerifyCache/16384    	       7	 145889137 ns/op
PASS
ok  	github.com/ava-labs/hypersdk/crypto	95.193s

Before(~100ms/10k txs):
image

After (~45ms/10k txs):
image

Notably, there is no wait on signatures anymore in Verify.

TODO

@patrick-ogrady patrick-ogrady changed the title [crypto/ed25519] ed25519 batch verify [crypto/ed25519] ed25519 Batch Verify Aug 8, 2023
@patrick-ogrady patrick-ogrady changed the title [crypto/ed25519] ed25519 Batch Verify [crypto/ed25519] ed25519 Concurrent Batch Verify Aug 10, 2023
@patrick-ogrady patrick-ogrady changed the title [crypto/ed25519] ed25519 Concurrent Batch Verify [crypto/ed25519] ed25519 Concurrent Batch Verification Aug 10, 2023
* add batch support to chain

* making progress on sketch

* keep making progress

* add to block

* add batch structure

* add support in VM

* mvp should be hooked up

* use max instead of min

* make batch filling async

* fix parse regression

* add ed25519 cache

* add auth caching

* create new ed25519 package

* cleanup auth_batch

* more cleanup of auth_batch

* add missing license to auth batch

* cleanup usage in chain/block

* clarify placement of GetAuthBatchVerifier

* cleanup crypto errors

* update workers docs

* cleanup vm/dependencies

* update vm

* implement auth engine lookup

* fix auth package

* use pre-defined errors

* fix compilation

* fix tokenvm compilation

* gofmtpt

* update mocks

* cleanup load test

* cleanup load test
@patrick-ogrady patrick-ogrady marked this pull request as ready for review August 11, 2023 20:12
@patrick-ogrady patrick-ogrady changed the title [crypto/ed25519] ed25519 Concurrent Batch Verification [crypto/ed25519] ed25519 Concurrent Batch Verification + ZIP-215 Enforcement Aug 11, 2023
@patrick-ogrady patrick-ogrady merged commit ef249e2 into main Aug 11, 2023
27 checks passed
@patrick-ogrady patrick-ogrady deleted the ed25519-batch-verify branch August 11, 2023 21: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.

[crypto/ed25519] Test Batch Signature Verification Support
1 participant