Skip to content

Commit

Permalink
feat(verifier-Arduino): Add Arduino file
Browse files Browse the repository at this point in the history
  • Loading branch information
kkirkov authored and zah committed Jan 24, 2024
1 parent 600c1f3 commit f7e7613
Show file tree
Hide file tree
Showing 4 changed files with 700 additions and 0 deletions.
26 changes: 26 additions & 0 deletions Arduino/scr.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/usr/bin/env bash

rm -rf verify/mycache

ROOT="$(git rev-parse --show-toplevel)"

cp "${ROOT}/vendor/nim/lib/nimbase.h" "Arduino/verify"

nim c -r \
--cpu:esp \
-d:release \
-d:danger \
--opt:size \
--verbosity:3 \
--os:standalone \
--noMain:on \
--deadCodeElim:on \
--d:CTT_32=1 \
--d:CTT_ASM=false \
--nimcache:Arduino/verify/mycache \
--lib:"${ROOT}/vendor/nim/lib/" "${ROOT}/contracts/cosmos/verifier/verifier-constantine/lib/nim/verify/verify.nim"

rm "${ROOT}/verify/@"
rm Arduino/verify/@

cp -r "${ROOT}/Arduino/verify/mycache/." "${ROOT}/Arduino/verify"
27 changes: 27 additions & 0 deletions Arduino/verify/import.hh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#include <array>
#include <cstdint>
#include <vector>
const uint32_t ROOT_LENGTH = 32;
const uint32_t VERIFICATION_KEY_LENGTH = 640;
const uint32_t PROOF_LENGTH = 256;

extern "C" {
bool makePairsAndVerify(std::array<uint8_t, VERIFICATION_KEY_LENGTH> *vk,
std::array<uint8_t, PROOF_LENGTH> *prf,
std::array<uint8_t, ROOT_LENGTH> *currentHeaderHash,
std::array<uint8_t, ROOT_LENGTH> *newOptimisticHeader,
std::array<uint8_t, ROOT_LENGTH> *newFinalizedHeader,
std::array<uint8_t, ROOT_LENGTH> *newExecutionStateRoot,
std::array<uint8_t, 8> *currentSlot,
std::array<uint8_t, ROOT_LENGTH> *domain);
}

std::array<uint8_t, VERIFICATION_KEY_LENGTH> vkey = { 23, 14, 17, 42, 185, 164, 205, 1, 195, 107, 171, 71, 64, 46, 252, 207, 233, 238, 75, 26, 225, 17, 222, 60, 207, 94, 92, 15, 152, 2, 235, 6, 30, 139, 14, 214, 223, 44, 75, 49, 54, 176, 41, 90, 23, 66, 228, 60, 120, 2, 126, 203, 170, 53, 127, 17, 146, 101, 59, 78, 218, 81, 70, 6, 224, 39, 103, 0, 74, 163, 104, 212, 12, 80, 4, 180, 153, 193, 41, 121, 104, 119, 103, 167, 254, 129, 4, 245, 126, 30, 115, 6, 90, 118, 243, 42, 88, 62, 102, 201, 100, 28, 210, 51, 27, 159, 235, 14, 105, 41, 0, 200, 191, 106, 23, 217, 230, 36, 64, 114, 191, 133, 13, 1, 47, 144, 202, 41, 54, 145, 20, 235, 167, 131, 110, 143, 205, 16, 96, 55, 239, 135, 252, 114, 36, 250, 52, 248, 199, 18, 198, 164, 218, 225, 83, 161, 169, 138, 117, 21, 52, 72, 248, 169, 122, 13, 36, 24, 168, 117, 136, 211, 252, 64, 182, 185, 249, 202, 91, 35, 140, 89, 89, 45, 244, 198, 204, 171, 3, 231, 194, 42, 38, 32, 188, 2, 209, 181, 131, 142, 114, 1, 123, 73, 53, 25, 235, 220, 223, 26, 129, 151, 71, 38, 184, 251, 59, 80, 150, 175, 65, 56, 87, 25, 64, 97, 76, 168, 125, 115, 180, 175, 196, 216, 2, 88, 90, 221, 67, 96, 134, 47, 160, 82, 252, 80, 233, 9, 107, 123, 234, 58, 131, 240, 254, 20, 246, 233, 107, 136, 157, 250, 157, 97, 120, 155, 158, 245, 151, 210, 127, 254, 254, 125, 27, 35, 98, 26, 158, 255, 6, 66, 158, 174, 235, 126, 253, 40, 238, 86, 24, 199, 86, 91, 9, 100, 187, 60, 125, 50, 34, 249, 87, 220, 118, 16, 53, 51, 190, 53, 249, 85, 130, 100, 253, 147, 230, 160, 164, 13, 38, 32, 188, 2, 209, 181, 131, 142, 114, 1, 123, 73, 53, 25, 235, 220, 223, 26, 129, 151, 71, 38, 184, 251, 59, 80, 150, 175, 65, 56, 87, 25, 64, 97, 76, 168, 125, 115, 180, 175, 196, 216, 2, 88, 90, 221, 67, 96, 134, 47, 160, 82, 252, 80, 233, 9, 107, 123, 234, 58, 131, 240, 254, 20, 246, 233, 107, 136, 157, 250, 157, 97, 120, 155, 158, 245, 151, 210, 127, 254, 254, 125, 27, 35, 98, 26, 158, 255, 6, 66, 158, 174, 235, 126, 253, 40, 238, 86, 24, 199, 86, 91, 9, 100, 187, 60, 125, 50, 34, 249, 87, 220, 118, 16, 53, 51, 190, 53, 249, 85, 130, 100, 253, 147, 230, 160, 164, 13, 111, 184, 203, 90, 60, 233, 99, 208, 105, 198, 17, 27, 170, 63, 164, 235, 89, 138, 44, 71, 77, 86, 250, 114, 158, 185, 210, 144, 64, 123, 239, 15, 222, 231, 138, 155, 249, 201, 152, 185, 180, 32, 216, 18, 207, 224, 200, 78, 1, 247, 107, 24, 113, 8, 25, 234, 251, 192, 200, 141, 43, 46, 140, 23, 164, 85, 253, 109, 87, 59, 29, 233, 190, 58, 38, 152, 86, 64, 105, 96, 128, 159, 187, 178, 215, 58, 254, 153, 85, 233, 92, 71, 19, 51, 251, 33, 186, 68, 84, 84, 140, 220, 78, 252, 153, 242, 177, 175, 140, 197, 148, 55, 7, 168, 10, 217, 103, 64, 0, 103, 105, 55, 253, 67, 105, 214, 53, 1, 233, 8, 55, 162, 182, 137, 134, 184, 120, 76, 43, 200, 104, 163, 181, 240, 252, 165, 124, 79, 220, 228, 61, 80, 175, 50, 53, 146, 249, 235, 55, 0, 135, 66, 42, 148, 149, 40, 192, 246, 199, 22, 166, 43, 56, 111, 130, 160, 181, 83, 4, 152, 147, 169, 193, 149, 171, 188, 60, 231, 177, 95, 116, 14};
std::array<uint8_t, PROOF_LENGTH> proof = {30, 31, 60, 34, 210, 253, 202, 188, 172, 17, 13, 195, 160, 133, 195, 248, 167, 90, 22, 66, 237, 150, 134, 176, 188, 178, 113, 59, 77, 148, 207, 34, 236, 137, 248, 203, 253, 208, 212, 7, 153, 35, 45, 200, 105, 130, 55, 66, 21, 185, 243, 136, 230, 181, 65, 75, 81, 83, 236, 151, 236, 15, 247, 8, 192, 84, 28, 96, 230, 70, 19, 21, 108, 148, 41, 240, 197, 112, 162, 142, 198, 76, 121, 146, 156, 117, 91, 38, 239, 62, 181, 132, 131, 15, 112, 44, 152, 62, 117, 248, 197, 213, 8, 253, 161, 126, 171, 180, 6, 182, 12, 41, 6, 137, 255, 36, 235, 125, 235, 130, 73, 73, 5, 15, 159, 85, 72, 0, 24, 147, 115, 166, 1, 111, 86, 222, 208, 66, 124, 179, 64, 133, 168, 0, 122, 2, 52, 2, 103, 239, 45, 102, 77, 120, 140, 250, 114, 194, 220, 34, 46, 134, 1, 15, 77, 68, 140, 70, 203, 189, 192, 83, 142, 113, 147, 85, 78, 88, 99, 134, 116, 58, 141, 228, 135, 41, 16, 245, 187, 58, 51, 17, 52, 178, 184, 140, 13, 86, 10, 222, 152, 56, 100, 66, 57, 4, 217, 71, 104, 236, 245, 106, 25, 236, 242, 212, 229, 88, 130, 153, 210, 139, 151, 28, 232, 226, 187, 1, 140, 2, 100, 48, 119, 51, 37, 67, 186, 178, 240, 243, 197, 100, 124, 10, 53, 52, 100, 176, 24, 95, 238, 38, 227, 183, 133, 24};
std::array<uint8_t, ROOT_LENGTH> currentHeader = {76, 231, 107, 116, 120, 203, 14, 238, 74, 50, 199, 242, 91, 181, 97, 202, 29, 15, 68, 77, 23, 22, 200, 246, 242, 96, 144, 14, 244, 95, 55, 210};
std::array<uint8_t, ROOT_LENGTH> newOptimisticHeader = {224, 132, 253, 242, 42, 114, 188, 147, 160, 185, 117, 205, 215, 245, 192, 90, 14, 9, 0, 34, 219, 97, 218, 241, 110, 95, 76, 216, 87, 111, 211, 171};
std::array<uint8_t, ROOT_LENGTH> newFinalizedHeader = {136, 59, 86, 215, 36, 97, 240, 88, 164, 76, 237, 14, 37, 50, 111, 115, 134, 120, 129, 207, 42, 6, 20, 39, 143, 233, 102, 217, 21, 236, 105, 23};
std::array<uint8_t, ROOT_LENGTH> newExecutionStateRoot = {100, 107, 155, 135, 186, 7, 66, 136, 107, 248, 51, 46, 14, 126, 245, 198, 197, 223, 2, 219, 5, 34, 196, 6, 33, 240, 220, 87, 150, 72, 208, 3};

std::array<uint8_t, ROOT_LENGTH> domain = {7, 0, 0, 0, 98, 137, 65, 239, 33, 209, 254, 140, 113, 52, 114, 10, 221, 16, 187, 145, 227, 176, 44, 0, 126, 0, 70, 210, 71, 44, 102, 149};
std::array<uint8_t, 8> new_slot = {109, 150, 85, 0, 0, 0, 0, 0};
Loading

0 comments on commit f7e7613

Please sign in to comment.