{"_id":"@buk_i/era-js","name":"@buk_i/era-js","dist-tags":{"latest":"0.1.0"},"versions":{"0.1.0":{"name":"@buk_i/era-js","type":"module","collaborators":["BukiOffor <ebuka2264@yahoo.com>"],"description":"A package that handles the cryptographic operations for the ERA project","version":"0.1.0","license":"MIT/Apache-2.0","repository":{"type":"git","url":"git+https://github.com/BukiOffor/era-js.git"},"main":"era_js.js","types":"era_js.d.ts","sideEffects":["./era_js.js","./snippets/*"],"_id":"@buk_i/era-js@0.1.0","gitHead":"98694d97ed1739ea078c8770a70c2ad5fe327425","bugs":{"url":"https://github.com/BukiOffor/era-js/issues"},"homepage":"https://github.com/BukiOffor/era-js#readme","_nodeVersion":"23.10.0","_npmVersion":"10.9.2","dist":{"integrity":"sha512-JOxRsydGUqSqxUmCHHeez/sVwuitaP+34u29wGYMhxocT0T62x+R6Ms+sHOlkUURg4X3tw93RKT7DnwEIpbMIg==","shasum":"9737fa2029b6c03a9077b8542379b74d255de160","tarball":"https://registry.npmjs.org/@buk_i/era-js/-/era-js-0.1.0.tgz","fileCount":8,"unpackedSize":679780,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCIHpwuBhn9hpTOZd5ZerzZ4CjiF64iNIhMnLNQOAh+JZ1AiAvW3a8x/wi4oCAcW+oFZGnMt5U6USqsGsxNOpUdn88pA=="}]},"_npmUser":{"name":"buk_i","email":"ebuka2264@yahoo.com"},"directories":{},"maintainers":[{"name":"buk_i","email":"ebuka2264@yahoo.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/era-js_0.1.0_1748640683997_0.9879134903142588"},"_hasShrinkwrap":false}},"time":{"created":"2025-05-30T21:31:23.899Z","0.1.0":"2025-05-30T21:31:24.333Z","modified":"2025-05-30T21:31:24.589Z"},"maintainers":[{"name":"buk_i","email":"ebuka2264@yahoo.com"}],"description":"A package that handles the cryptographic operations for the ERA project","homepage":"https://github.com/BukiOffor/era-js#readme","repository":{"type":"git","url":"git+https://github.com/BukiOffor/era-js.git"},"bugs":{"url":"https://github.com/BukiOffor/era-js/issues"},"license":"MIT/Apache-2.0","readme":"# era-js\n\nA WebAssembly-powered cryptographic toolkit for the ERA project, providing secure wallet shard management and Reed-Solomon erasure coding for robust key recovery.\n\n## Features\n\n- **WebAssembly (WASM) bindings** for high-performance cryptographic operations in JavaScript.\n- **Reed-Solomon erasure coding** for secure wallet shard reconstruction and fault tolerance.\n- **Serde-based deserialization** for seamless integration with JavaScript objects.\n- **Dual-licensed** under MIT and Apache-2.0 for maximum compatibility.\n\n## Installation\n\nInstall via npm (after building with `wasm-pack`):\n\n```sh\nnpm install era-js\n```\n\nOr use directly in your JavaScript/TypeScript project by importing the generated WASM and JS files.\n\n## Usage\n\n### Importing\n\n```js\nimport init, { BaseWallet } from 'era-js';\n// or, if using the generated JS directly:\nimport { BaseWallet } from './era_js.js';\n```\n\n### Example: Reconstructing Wallet Shards\n\n```js\n// Example wallet shards (Uint8Array or array of numbers)\nconst walletData = {\n  project_shard: [/* ... */],\n  system_shard: [/* ... */],\n  recovery_shard: [/* ... */]\n};\n\nconst wallet = new BaseWallet(walletData);\nconst reconstructed = wallet.reconstruct_shards();\n// `reconstructed` is a Uint8Array containing the combined data shards\n```\n\n## API\n\n### `BaseWallet`\n\n#### Constructor\n\n```typescript\nnew BaseWallet(value: object): BaseWallet\n```\n- `value`: An object with optional `project_shard`, `system_shard`, and `recovery_shard` fields (each a `Uint8Array` or array of bytes).\n\n#### Methods\n\n- `reconstruct_shards(): Uint8Array`\n  - Reconstructs the original data from the provided shards using Reed-Solomon coding.\n  - Throws if reconstruction or verification fails.\n\n## How It Works\n\n1. **Shard Storage:** The wallet generates up to three shards: `project_shard`, `system_shard`, and `recovery_shard`.\n2. **Reconstruction:** Using Reed-Solomon coding (2 data shards, 3 parity shards), the wallet can reconstruct the original key material even if some shards are missing.\n3. **Verification:** The reconstructed shards are verified for integrity before combining.\n\n## Building from Source\n\nEnsure you have [Rust](https://www.rust-lang.org/tools/install) and [wasm-pack](https://rustwasm.github.io/wasm-pack/installer/) installed.\n\n```sh\nwasm-pack build\n```\n\nThis will generate the WASM and JS bindings in the `pkg/` directory.\n\n## Testing\n\nRun Rust tests:\n\n```sh\ncargo test\n```\n\nOr test the WASM package in headless browsers:\n\n```sh\nwasm-pack test --headless --firefox\n```\n\n## License\n\nLicensed under either of\n\n- Apache License, Version 2.0 ([LICENSE_APACHE](LICENSE_APACHE) or http://www.apache.org/licenses/LICENSE-2.0)\n- MIT license ([LICENSE_MIT](LICENSE_MIT) or http://opensource.org/licenses/MIT)\n\nat your option.\n\n### Contribution\n\nUnless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.\n\n---\n\nFor more details, see the [pkg/README.md](pkg/README.md) and [src/era/wallet.rs](src/era/wallet.rs) files.","readmeFilename":"README.md","_rev":"1-1f0fff8d1b787344bb7fc142293325f3"}