Skip to content

anemoi doc #3

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 42 additions & 3 deletions content/zytron/precompiles/anemoi.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,47 @@ let data = ethabi::encode(&[

## Javascript SDK

> TODO
```javascript
const wasm = require('./pkg/wasm.js');

let f1 = "0x2f8dd1f1a7583c42c4e12a44e110404c73ca6c94813f85835da4fb7bb1301d4a";
let f2 = "0x1ee678a0470a75a6eaa8fe837060498ba828a3703b311d0f77f010424afeb025";
let f3 = "0x2042a587a90c187b0a087c03e29c968b950b1db26d5c82d666905a6895790c0a";

ret = wasm.anemoi_hash([f1, f2, f3]);
console.log(ret)

## C SDK

> TODO
```

## C SDK
```c
#include "c-uzkge.h"

int main(int argc, char *argv[])
{
char f1_array[] = {47, 141, 209, 241, 167, 88, 60, 66, 196, 225, 42, 68, 225, 16, 64, 76, 115, 202, 108, 148, 129, 63, 133, 131, 93, 164, 251, 123, 177, 48, 29, 74};
struct Bytes f1;
f1.len = sizeof(f1_array);
f1.data = f1_array;
char f2_array[] = {30, 230, 120, 160, 71, 10, 117, 166, 234, 168, 254, 131, 112, 96, 73, 139, 168, 40, 163, 112, 59, 49, 29, 15, 119, 240, 16, 66, 74, 254, 176, 37};
struct Bytes f2;
f2.len = sizeof(f2_array);
f2.data = f2_array;
char f3_array[] = {32, 66, 165, 135, 169, 12, 24, 123, 10, 8, 124, 3, 226, 156, 150, 139, 149, 11, 29, 178, 109, 92, 130, 214, 102, 144, 90, 104, 149, 121, 12, 10};
struct Bytes f3;
f3.len = sizeof(f3_array);
f3.data = f3_array;
Bytes data[3] = {f1, f2, f3};

char ret_val[32] = {0};
int res = __anemoi_hash(data, sizeof(data) / sizeof(data[0]), ret_val);
printf("hash:");
for (int i = 0; i < sizeof(ret_val); i++)
{
printf("%u,", ret_val[i]);
}
printf("\n");
return res;
}
、、、
61 changes: 58 additions & 3 deletions content/zytron/precompiles/ed-on-bn254.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,64 @@ let data = ethabi::encode(&[Token::Uint(scalar), Token::Uint(p1_x), Token::Uint(
```

## Javascript SDK
```javascript
const wasm = require('./pkg/wasm.js');

> TODO
let x1 = "0x0d52c3aa573af39845660735de0d3d9efb481a112cf00623ab22546122d4e16a";
let y1 = "0x0e7e20b3cb30785b64cd6972e2ddf919db64d03d6cf01456243c5ef2fb766a65";
let x2 = "0x242cbada3ae8d6e90056e73e4941eeccee72cb99945a194f754205b3678bd769";
let y2 = "0x2d7690deeaa77c9d89b0ceb3c25f7bb09c44f40b4b8cf5d6fcb512c7be8fcba9";

## C SDK
ret = wasm.point_add(x1, y1, x2, y2);
console.log(ret)

let s = "0x008d7a42a4dde1d8f8bcacddcae9bc78b1480eb547d4a490d9cfa5c268a076c7";
let x = "0x1738fd301654d891e32235d03a64b7ebe0c3f37df67db0b798f2664783b1bac9";
let y = "0x22a689a1c0aebf70ceee76fe7891729002e072ceb7ba94a32b1fce79f8c009d9";

> TODO
ret = wasm.scalar_mul(s, x, y);
console.log(ret)
```
## C SDK
```c
#include "c-uzkge.h"

int point_add()
{
char x1[] = {13, 82, 195, 170, 87, 58, 243, 152, 69, 102, 7, 53, 222, 13, 61, 158, 251, 72, 26, 17, 44, 240, 6, 35, 171, 34, 84, 97, 34, 212, 225, 106};
char y1[] = {14, 126, 32, 179, 203, 48, 120, 91, 100, 205, 105, 114, 226, 221, 249, 25, 219, 100, 208, 61, 108, 240, 20, 86, 36, 60, 94, 242, 251, 118, 106, 101};
char x2[] = {36, 44, 186, 218, 58, 232, 214, 233, 0, 86, 231, 62, 73, 65, 238, 204, 238, 114, 203, 153, 148, 90, 25, 79, 117, 66, 5, 179, 103, 139, 215, 105};
char y2[] = {45, 118, 144, 222, 234, 167, 124, 157, 137, 176, 206, 179, 194, 95, 123, 176, 156, 68, 244, 11, 75, 140, 245, 214, 252, 181, 18, 199, 190, 143, 203, 169};
char ret_val[32] = {0};
int res = __point_add(x1, x2, y1, y2, ret_val);
printf("hash:");
for (int i = 0; i < sizeof(ret_val); i++)
{
printf("%u,", ret_val[i]);
}
printf("\n");
return res;
}

int scalar_mul()
{
char s[] = {0, 141, 122, 66, 164, 221, 225, 216, 248, 188, 172, 221, 202, 233, 188, 120, 177, 72, 14, 181, 71, 212, 164, 144, 217, 207, 165, 194, 104, 160, 118, 199};
char x[] = {23, 56, 253, 48, 22, 84, 216, 145, 227, 34, 53, 208, 58, 100, 183, 235, 224, 195, 243, 125, 246, 125, 176, 183, 152, 242, 102, 71, 131, 177, 186, 201};
char y[] = {34, 166, 137, 161, 192, 174, 191, 112, 206, 238, 118, 254, 120, 145, 114, 144, 2, 224, 114, 206, 183, 186, 148, 163, 43, 31, 206, 121, 248, 192, 9, 217};
char ret_val[32] = {0};
int res = __scalar_mul(s, x, y, ret_val);
printf("hash:");
for (int i = 0; i < sizeof(ret_val); i++)
{
printf("%u,", ret_val[i]);
}
printf("\n");
return res;
}

int main(int argc, char *argv[])
{
printf("point_add:%d\n", point_add());
printf("scalar_mul:%d\n", scalar_mul());
}
```
Loading