There are 3 circuits for Chacha (v1, v2, v3) 2 circuits for AES (v1, v2) V3 ChaCha20 and V2 AES are the most efficient implementations:
-
ChaCha20 V3:
- Operates on individual bits
- Optimized for smaller circuit size & better overall performance
-
AES V2:
- Employs lookup tables for transformations
- Avoids on-the-fly calculations, resulting in faster execution
- Significantly improves efficiency compared to the previous version
These optimized versions provide the best balance of speed and resource usage for their respective algorithms.
Prover library runs on Client side Android, IOS and Linux for generating proofs Verifier library runs on Server side Linux (X64 and ARM64) only for verifying proofs
An example input to the library would be:
{
"cipher": "chacha20",
"key": "AgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgI=",
"nonce": "AwMDAwMDAwMDAwMD",
"counter": 3,
"input": "3w1sF8DskL0dfh4th6ONUvcPIiCvZVYoPUZw0B2Oo0Vv9GiuG4QJCSM/vyRT2HM0b9IcM03fkTPpSAEcozH59Q=="
}
all binary fields are base64 encoded
input
is either plaintext or ciphertext, it does not matter with CTR mode
An example output is:
{
"proof": {
"proofJson": "3rJu6SuPFBPDaCLxUdkYnIIoX0rAPOZqj/COpmFPZCueaxhfSs+tY8AbJy1vh0xdTPE4wanvPkK6gVDGAZFUkwJqzjV2t3Fufxh509I4Nt0LxAK0f6vofjAf0SYkFQ2OqaQxQkPaKXJvVoi7KNClPg0WWYNPxpNesaOaZ2pXVBMAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA="
},
"publicSignals": "4R7wsubT5FCrGjUJwKaix57OE3aooKbAlgPyaxWxBt7mBxHXCcohrH5UX30sBA8boZM9Tv9II6FC2nqv+kgyJA=="
}
where publicSignals
is the corresponding plaintext or ciphertext
go run keygen.go
Proving keys & compiled circuits will be here Verification keys will be here
go test ./...
cd libraries
go test -bench=.
Library files are located at
libraries/prover/libprove.go
libraries/verifier/libverify.go
install latest NDK: set CC and CXX (use your paths)
CC=android/ndk-bundle/toolchains/llvm/prebuilt/linux-x86_64/bin/x86_64-linux-android30-clang CXX=android/ndk-bundle/toolchains/llvm/prebuilt/linux-x86_64/bin/x86_64-linux-android30-clang++ CGO_ENABLED=1 GOOS=android GOARCH=amd64 go build -trimpath -ldflags="-s -w" -buildmode=c-shared -o libprove.so libraries/prover/libprove.go
CC=android/ndk-bundle/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android30-clang CXX=android/ndk-bundle/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android30-clang++ CGO_ENABLED=1 GOOS=android GOARCH=arm64 go build -trimpath -ldflags="-s -w" -buildmode=c-shared -o libprove.so libraries/prover/libprove.go
CGO_ENABLED=1 GOOS=linux GOARCH=amd64 go build -trimpath -ldflags '-s -w' -buildmode=c-shared -o libprove.so libraries/prover/libprove.go
CGO_ENABLED=1 GOOS=linux GOARCH=amd64 go build -trimpath -ldflags '-s -w' -buildmode=c-shared -o libverify.so libraries/verifier/libverify.go
CC=aarch64-linux-gnu-gcc CGO_ENABLED=1 GOOS=linux GOARCH=arm64 go build -trimpath -ldflags="-s -w" -buildmode=c-shared -o libprove.so libraries/prover/libprove.go
CC=aarch64-linux-gnu-gcc CGO_ENABLED=1 GOOS=linux GOARCH=arm64 go build -trimpath -ldflags="-s -w" -buildmode=c-shared -o libverify.so libraries/verifier/libverify.go