Skip to content

Commit

Permalink
ESM module migration (#21)
Browse files Browse the repository at this point in the history
* ESM module migration

* Update typescript

* Add to bigInt function for PK

* 1.2.0

* Format

* Renaming. Fix lint

* Update package version

* Update package lock

* Update package lock

* Update package lock

* add audited blake hash. Fix esm for node

* Fixes
  • Loading branch information
Kolezhniuk authored Feb 18, 2025
1 parent 5efe996 commit 116bdb3
Show file tree
Hide file tree
Showing 24 changed files with 3,385 additions and 3,800 deletions.
33 changes: 0 additions & 33 deletions .eslintrc.js

This file was deleted.

4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/node_modules
coverage
/coverage
dist
.DS_Store
.idea
.vscode
.vscode
7 changes: 0 additions & 7 deletions config/tsconfig.esm.json

This file was deleted.

3 changes: 3 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import config from '@iden3/eslint-config';

export default config;
37 changes: 13 additions & 24 deletions index.html
Original file line number Diff line number Diff line change
@@ -1,33 +1,24 @@
<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible"
content="IE=edge">
<meta name="viewport"
content="width=device-width, initial-scale=1.0">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<script src="./dist/browser/umd/index.js"></script>
<title>Test</title>
</head>
</head>

<body>
<body>
Test browser
</body>
<script>
// Function to convert hex to base64
function base64FromHex(hex) {
hex = hex.replace(/^0x/, '');
hex = hex.length % 2 != 0 ? '0' + hex : hex;
const buffer = new Uint8Array(hex.match(/.{1,2}/g).map((byte) => parseInt(byte, 16)));
return btoa(String.fromCharCode(...buffer));
}

const { poseidon, PrivateKey, Signature, utils, ffUtils, Hex } = IdenJsCrypto;
</body>
<script>
const { PrivateKey, Signature, utils, ffUtils, Hex } = IdenJsCrypto;
const msgBuf = Hex.decodeString('000102030405060708090000');
const msg = ffUtils.leBuff2int(msgBuf);

const skBuff = Hex.decodeString('0001020304050607080900010203040506070809000102030405060708090001');
const skBuff = Hex.decodeString(
'0001020304050607080900010203040506070809000102030405060708090001'
);

const privateKey = new PrivateKey(skBuff);

Expand All @@ -38,12 +29,10 @@

const signature = privateKey.signPoseidon(msg);


const pSignature = signature.compress();

const uSignature = Signature.newFromCompressed(pSignature);

console.assert(pubKey.verifyPoseidon(msg, uSignature));
</script>

</script>
</html>
4 changes: 0 additions & 4 deletions jest.config.ts

This file was deleted.

Loading

0 comments on commit 116bdb3

Please sign in to comment.