Security News
Input Validation Vulnerabilities Dominate MITRE's 2024 CWE Top 25 List
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
@spacemesh/address-wasm
Advanced tools
This package implements BECH32 address encoder and verifier.
To start using the library you need to install it first:
yarn add @spacemesh/address-wasm
And then start using it in your code:
import Bech32 from '@spacemesh/address-wasm'
(async () => {
// Initialize wasm
// Init function requires an HRPNetwork string
// It will be called automatically on calling any of methods
// in case it was not called before.
Bech32.init();
// Then you can setHRPNetwork:
Bech32.setHRPNetwork('sm');
// Get some public key
const publicKey = Uint8Array.from([1, 2, 3, ..., 20]);
// And generate address from it
const addr = Bech32.generateAddress(publicKey);
// You can also verify it
console.log(Bech32.verify(addr)); // true
// Then you can change HRP Network
Bech32.setHRPNetwork('smtest');
// And now previously generated address becomes invalid,
// because it refers to different HRP network
console.log(Bech32.verify(addr)); // false
// And get byte-representation of the address:
console.log(Bech32.parse(addr)); // [0, 0, 0, 0, 1, 2, ..., 20]
})();
// You can also call `verify`, `parse`, `generateAddress` methods
// with second argument: HRP. Then it will behave like pure function.
console.log(Bech32.generateAddress(publicKey, 'sm')); // 'sm1q...'
console.log(Bech32.generateAddress(publicKey, 'stest')); // 'stest1q...'
console.log(Bech32.verify(someAddr, 'stest')); // true / false
This package contains Wasm implementation in golang, that uses spacemeshos/address
implementation inside.
Also, package includes Javascript wrapper over Wasm runner, that provides a clean facade for functions.
You will need to install Go (check out version in go.mod
), NodeJS and yarn.
Then you can just type:
make
To run different build processes — check out Makefile. For example to build only wasm file you can run
make gen-wasm
FAQs
WASM-Implementation of BECH32 address codec
We found that @spacemesh/address-wasm demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 4 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.
Research
Security News
A threat actor's playbook for exploiting the npm ecosystem was exposed on the dark web, detailing how to build a blockchain-powered botnet.