//! SPDX-License-Identifier: GPL-3.0-or-later\r
\r
import { Blake2b } from './blake2b'\r
-import { ChangeBlock, ReceiveBlock, SendBlock } from './block'\r
import { ACCOUNT_KEY_BYTE_LENGTH, ACCOUNT_KEY_HEX_LENGTH, ALPHABET, PREFIX, PREFIX_LEGACY } from './constants'\r
import { base32, bytes, hex, utf8 } from './convert'\r
import { NanoNaCl } from './nano-nacl'\r
*/\r
static import (keypairs: KeyPair[]): Account[]\r
/**\r
- * Instantiates an Account object from its private key which is then encrypted\r
- * and stored in IndexedDB. The corresponding public key will automatically be\r
- * derived and saved.\r
+ * Instantiates an Account object from its private key which is used to derive\r
+ * a public key and then discarded. The public key is saved in the database.\r
*\r
* @param {KeyPair} keypair - Index and keys of the account\r
* @param {Key} password - Used to encrypt the private key\r
*/\r
static async import (keypair: KeyPair, password: Key): Promise<Account>\r
/**\r
- * Instantiates Account objects from their private keys which are then\r
- * encrypted and stored in IndexedDB. The corresponding public keys will\r
- * automatically be derived and saved.\r
+ * Instantiates Account objects from their private keys which are used to\r
+ * derive public keys and then discarded. The public keys are saved in the\r
+ * database.\r
*\r
* @param {KeyPair[]} keypairs - Indexes and keys of the accounts\r
* @param {Key} password - Used to encrypt the private keys\r
let index\r
for (let keypair of keypairs) {\r
let keyError, addressError\r
- const key = keypair.publicKey\r
+ const key = keypair.publicKey instanceof ArrayBuffer\r
+ ? new Uint8Array(keypair.publicKey)\r
+ : keypair.publicKey\r
try {\r
this.#validateKey(key)\r
publicKey = (typeof key === 'string')\r
if (key === undefined) {\r
throw new TypeError(`Key is undefined`)\r
}\r
+ if (key instanceof ArrayBuffer) {\r
+ key = new Uint8Array(key)\r
+ }\r
if (typeof key !== 'string' && !(key instanceof Uint8Array)) {\r
throw new TypeError(`Key must be a string or Uint8Array`)\r
}\r