import type { Bip32Path } from "@iota/crypto.js" ; import { Bip39 , Ed25519 , Slip0010 } from "@iota/crypto.js" ; import type { IKeyPair } from "../models/IKeyPair" ; import type { ISeed } from "../models/ISeed" ; /**
 * The global type for the seed.
 */ export const ED25519_SEED_TYPE = 1 ; /**
 * Class to help with seeds.
 */ export class Ed25519Seed implements ISeed { internal private readonly _secretKey : Uint8Array ; param secretKeyBytes constructor ( secretKeyBytes ? ) { this . _secretKey = secretKeyBytes ?? new Uint8Array ( ) ; } param mnemonic returns public static fromMnemonic ( mnemonic ) { return new Ed25519Seed ( Bip39 . mnemonicToSeed ( mnemonic ) ) ; } returns public keyPair ( ) { const signKeyPair = Ed25519 . keyPairFromSeed ( this . _secretKey ) ; return { publicKey : signKeyPair . publicKey , privateKey : signKeyPair . privateKey } ; } param path returns public generateSeedFromPath ( path ) { const keys = Slip0010 . derivePath ( this . _secretKey , path ) ; return new Ed25519Seed ( keys . privateKey ) ; } returns public toBytes ( ) { return this . _secretKey ; } }