hack-a-chain-software / opact-kadena

1 stars 0 forks source link

[CIRCUITS] Groth16 on Nitro Enclaves #69

Open davibauer opened 1 year ago

davibauer commented 1 year ago

Research

Docker

vSock

Nitro Enclaves

Witness

veigajoao commented 1 year ago

Dúvidas:

davibauer commented 1 year ago

A principal função do documento de atestação é fornecer uma garantia criptográfica de que um determinado enclave foi inicializado em um estado seguro e está executando um software específico. Ele pode incluir informações como:

No entanto, essas informações são geralmente insuficientes para reproduzir o "estado interno" do enclave, que incluiria coisas como:

davibauer commented 1 year ago

https://docs.aws.amazon.com/enclaves/latest/user/verify-root.html

davibauer commented 1 year ago

Visão geral do processo de atestação:

No Nitro Enclave:

No Host EC2:

No Cliente ou Terceira Parte Confiável:

davibauer commented 1 year ago

https://github.com/aws/aws-nitro-enclaves-nsm-api/blob/main/docs/attestation_process.md

davibauer commented 1 year ago

https://docs.aws.amazon.com/enclaves/latest/user/set-up-attestation.html

davibauer commented 1 year ago
PCR | Hash of ... | Description -- | -- | -- PCR0 | Enclave image file | A contiguous measure of the contents of the image file, without the section data. PCR1 | Linux kernel and bootstrap | A contiguous measurement of the kernel and boot ramfs data. PCR2 | Application | A contiguous, in-order measurement of the user applications, without the boot ramfs. PCR3 | IAM role assigned to the parent instance | A contiguous measurement of the IAM role assigned to the parent instance. Ensures that the attestation process succeeds only when the parent instance has the correct IAM role. PCR4 | Instance ID of the parent instance | A contiguous measurement of the ID of the parent instance. Ensures that the attestation process succeeds only when the parent instance has a specific instance ID. PCR8 | Enclave image file signing certificate | A measure of the signing certificate specified for the enclave image file. Ensures that the attestation process succeeds only when the enclave was booted from an enclave image file signed by a specific certificate.
veigajoao commented 1 year ago

Implementar imagem docker para:

davibauer commented 1 year ago

BENCHMARK

INSTANCE vCPUs: 16 | 4 | 16 | 4 RAM (GiB): 32 | 32 | 32 | 32 Disk (GiB): Used 323 MiB volume + 1.24 GiB docker image = ~1.6 GB Processor: 11th Gen Intel® Core™ i7-11800H @ 2.30GHz × 16

PHASE 1 - START A NEW POWERS OF TAU

Power: 17 | 17 | 20 | 14 | 14 Total execution time: 2s | 3s | 21s | 3s | 18s Max memory: 239MiB | 240.6MiB | 204.1MiB | 14.27MiB | 240MiB

snarkjs powersoftau new bn128 17 pot12_0000.ptau -v

PHASE 1 - CONTRIBUTE TO THE CERIMONY (1)

Total execution time: 40s | 1m54s | 5m45s | 5s | 18s Max memory: 386.7MiB | 414.2MiB | 886.5MiB | 247.6MiB | 241.1MiB

snarkjs powersoftau contribute pot12_0000.ptau pot12_0001.ptau --name="first contribution" -v -e="$RANDOM_NUMBER"

PHASE 1 - CONTRIBUTE TO THE CERIMONY (2)

Total execution time: 39s | 1m54s | 6m42s | 3s | 18s Max memory: 407.8MiB | 574.5MiB | 955.9MiB | 241.2MiB | 240.9MiB

snarkjs powersoftau contribute pot12_0001.ptau pot12_0002.ptau --name="first contribution" -v -e="$RANDOM_NUMBER"

PHASE 1 - CONTRIBUTE TO THE CERIMONY (3)

Total execution time: 39s | 1m58s | 5m7s | 18s Max memory: 464.3MiB | 394.1MiB | 960.7MiB | 245.1MiB

snarkjs powersoftau contribute pot12_0002.ptau pot12_0003.ptau --name="first contribution" -v -e="$RANDOM_NUMBER"

PHASE 1 - CONTRIBUTE TO THE CERIMONY (4)

Total execution time: 36s | 1m54s | 5m22s | 6s | 15s Max memory: 528.5MiB | 401.3MiB | 789.3MiB | 248MiB | 241.1MiB

snarkjs powersoftau contribute pot12_0003.ptau pot12_0004.ptau --name="first contribution" -v -e="$RANDOM_NUMBER"

PHASE 1 - CONTRIBUTE TO THE CERIMONY (5)

Total execution time: 38s | 1m55s | 5m16s | 6s | 15s Max memory: 553.8MiB | 390MiB | 955.9MiB | 241.3MiB | 244MiB

snarkjs powersoftau contribute pot12_0004.ptau pot12_0005.ptau --name="first contribution" -v -e="$RANDOM_NUMBER"

PHASE 1 - VERIFY CONTRIBUTION

Total execution time: 5s | 7s | 18s | - | 3s Max memory: 754.2MiB | 804.9MiB | 953.6MiB | - | 17.45MiB

snarkjs powersoftau verify pot12_0001.ptau -v

PHASE 2 - PREPARE

Total execution time: 14m | 34m22s | 1h 49m 26s | 1m 21s | 3m13s Max memory: 1.009GiB | 786.3MiB | 1.491GiB | 353.5MiB | 373.2MiB

snarkjs powersoftau prepare phase2 pot12_0001.ptau pot12_final.ptau -v

PHASE 2 - SETUP GROTH 16

Total execution time: 44s | 1m1s | 40s | 6s Max memory: 900.9MiB | 814.2MiB | 948.8MiB | 733.3MiB

snarkjs groth16 setup transaction.r1cs pot12_final.ptau transaction_0000.zkey

PHASE 2 - CONTRIBUTE

Total execution time: 11s | 15s | 9s | - | - Max memory: 278MiB | 282.1MiB | 322.2MiB | - | -

snarkjs zkey contribute transaction_0000.zkey transaction_0001.zkey --name="second contribution" -v -e="$RANDOM_NUMBER"
snarkjs zkey export verificationkey transaction_0001.zkey verification_key.json

PHASE 2 - CREATE PROOF

Total execution time: 8s | 9s | 6s | - | 3s Max memory: 997.5MiB | 972.7MiB | 1012MiB | - | 17.56MiB

snarkjs wtns check transaction.r1cs transaction.wtns
snarkjs groth16 prove transaction_0001.zkey transaction.wtns proof.json public.json
davibauer commented 1 year ago

Which instance types are supported?

Nitro Enclaves is currently supported on the majority of Graviton, Intel, and AMD-based Amazon EC2 instance types built on the AWS Nitro System. Nitro Enclaves is not currently available on bare metal instances, burstable instance types (e.g. T3), and instances with only 1 CPU core.

davibauer commented 1 year ago

Instance Configuration

Configuration vCPUs RAM (GiB)
Config 1 16 32
Config 2 4 32
Config 3 16 32
Config 4 4 32

Phase 1: Start A New Powers of Tau

Metrics Config 1 Config 2 Config 3 Config 4 Config 5
Power 17 17 20 14 14
Total Execution Time (s) 2 3 21 3 18
Max Memory (MiB) 239 240.6 204.1 14.27 240

Phase 1: Contribute to the Ceremony (1)

Metrics Config 1 Config 2 Config 3 Config 4 Config 5
Total Execution Time 40s 1m 54s 5m 45s 5s 18s
Max Memory (MiB) 386.7 414.2 886.5 247.6 241.1

Phase 1: Contribute to the Ceremony (2)

Metrics Config 1 Config 2 Config 3 Config 4 Config 5
Total Execution Time 39s 1m 54s 6m 42s 3s 18s
Max Memory (MiB) 407.8 574.5 955.9 241.2 240.9

Phase 1: Contribute to the Ceremony (3)

Metrics Config 1 Config 2 Config 3 Config 4 Config 5
Total Execution Time 39s 1m 58s 5m 7s 18s -
Max Memory (MiB) 464.3 394.1 960.7 245.1 -

Phase 1: Contribute to the Ceremony (4)

Metrics Config 1 Config 2 Config 3 Config 4 Config 5
Total Execution Time 36s 1m 54s 5m 22s 6s 15s
Max Memory (MiB) 528.5 401.3 789.3 248 241.1

Phase 1: Contribute to the Ceremony (5)

Metrics Config 1 Config 2 Config 3 Config 4 Config 5
Total Execution Time 38s 1m 55s 5m 16s 6s 15s
Max Memory (MiB) 553.8 390 955.9 241.3 244

Phase 1: Verify Contribution

Metrics Config 1 Config 2 Config 3 Config 4 Config 5
Total Execution Time (s) 5 7 18 - 3
Max Memory (MiB) 754.2 804.9 953.6 - 17.45

Phase 2: Prepare

Metrics Config 1 Config 2 Config 3 Config 4 Config 5
Total Execution Time 14m 34m 22s 1h 49m 26s 1m 21s 3m 13s
Max Memory (GiB/MiB) 1.009 GiB 786.3 MiB 1.491 GiB 353.5 MiB 373.2 MiB

Phase 2: Setup Groth 16

Metrics Config 1 Config 2 Config 3 Config 4 Config 5
Total Execution Time (s) 44 61 40 6 -
Max Memory (MiB) 900.9 814.2 948.8 733.3 -

Phase 2: Contribute

Metrics Config 1 Config 2 Config 3 Config 4 Config 5
Total Execution Time (s) 11 15 9 - -
Max Memory (MiB) 278 282.1 322.2 - -

Phase 2: Create Proof

Metrics Config 1 Config 2 Config 3 Config 4 Config 5
Total Execution Time (s) 8 9 6 - 3
Max Memory (MiB) 997.5 972.7 1012 - 17.56