Introduction
SASEUL JS makes it easy to generate a private key, a public key, and an address. These key pairs constitute a single address, and by creating multiple private keys from a seed, you can effectively manage multiple accounts.
If you need detailed information on SASEUL JS—such as supported methods, parameters, sample responses, and usage tips—please refer to the post linked below. In particular, be sure to review the “Generating Key Pair, Address and Signature” section to gain a clearer understanding of how to generate cryptographic keys and handle address creation and digital signatures. The link provides a comprehensive API reference, example code snippets, and important guidelines for using SASEUL JS safely and effectively.
- SASEUL JS Specification
(Through the above link, you can check API references, usage examples for each function, and considerations for proper usage.)
For additional clarity, you may also explore how SASEUL JS can handle cryptographic operations and manage multiple key pairs to streamline your account management process.
Cryptographic Algorithm Diagram and Examples
Below is a conceptual diagram illustrating the cryptographic algorithms employed by SASEUL JS. This overview can help you understand how key generation, encryption, and address creation operate under the hood.
Installing SASEUL JS
Use npm install saseul
to install.
Generating Keys and Verifying Addresses
Examples show how to generate key pairs, validate addresses, and handle each component. Make sure you implement secure storage for private keys.
Refer to the code below for details:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
/**
* generate-keypairs.js
*
* This example demonstrates how to generate key pairs,
* validate addresses, and handle each component (private key, public key, and address).
*/
const SASEUL = require('saseul');
// Generate an all-in-one key pair
// This gives you a private key, public key, and address at once.
let keypairs = SASEUL.Sign.keyPair();
console.log("Private Key (combined):", keypairs.private_key);
console.log("Public Key (combined):", keypairs.public_key);
console.log("Address (combined):", keypairs.address);
// Alternatively, generate each item separately
// 1. Private key
let private_key = SASEUL.Sign.privateKey();
// 2. Public key (requires private key as input)
let public_key = SASEUL.Sign.publicKey(private_key);
// 3. Address (requires public key as input)
let address = SASEUL.Sign.address(public_key);
console.log("Private Key (separate):", private_key);
console.log("Public Key (separate):", public_key);
console.log("Address (separate):", address);
// Validate addresses
// 1. Check a correct address
console.log("Is valid address:", SASEUL.Sign.addressValidity(address));
// 2. Check an incorrect address
console.log("Is valid address:", SASEUL.Sign.addressValidity("fc981d82177c3fdc1a41304691d8e53da71eb6848932"));
Generating Keys with a Seed
An example shows how to generate multiple key pairs from a single seed. In production, always store private keys securely.
Refer to the code below for details:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
/**
* seed-to-keypairs.js
*
* This example shows how to generate multiple key pairs from a seed.
* If you want to generate more key pairs, you can reduce the seed length
* and increase the pad length in the loop index (e.g., padStart())
* to allow for a larger range of values.
*/
const SASEUL = require('saseul');
// Generate a random 60-character hexadecimal string to use as the seed
let seed = SASEUL.Sign.privateKey().slice(0, -4);
// Create multiple key pairs by appending an index to the seed
for (let i = 0; i < 5; i++) {
// Combine the seed with a 4-digit hexadecimal index
let base = seed + i.toString(16).padStart(4, '0');
// Hash the combined string to derive a private key
let private_key = SASEUL.Enc.hash(base);
// Generate the public key from the private key
let public_key = SASEUL.Sign.publicKey(private_key);
// Generate the address from the public key
let address = SASEUL.Sign.address(public_key);
console.log("Derived Private Key:", private_key);
console.log("Derived Public Key:", public_key);
console.log("Derived Address:", address);
}
For actual working example files, please refer to the following GitHub link: