@yubing744/rooch-sdk
Version:
34 lines (33 loc) • 797 B
JavaScript
import { sha3_256 } from "@noble/hashes/sha3";
import { toSerializedSignature } from "./signature";
const PRIVATE_KEY_SIZE = 32;
const LEGACY_PRIVATE_KEY_SIZE = 64;
class BaseSigner {
async signMessage(bytes) {
const digest = sha3_256(bytes);
return this.signMessageWithHashed(digest);
}
async signMessageWithHashed(bytes) {
const signature = toSerializedSignature({
signature: await this.sign(bytes),
signatureScheme: this.getKeyScheme(),
pubKey: this.getPublicKey()
});
return {
signature,
bytes
};
}
toRoochAddress() {
return this.getPublicKey().toRoochAddress();
}
}
class Keypair extends BaseSigner {
}
export {
BaseSigner,
Keypair,
LEGACY_PRIVATE_KEY_SIZE,
PRIVATE_KEY_SIZE
};
//# sourceMappingURL=keypair.js.map