Skip to content

Instantly share code, notes, and snippets.

@taurenshaman
Created March 5, 2021 06:43
Show Gist options
  • Save taurenshaman/ed4dfd5019ade10e78a2dbacf24ac955 to your computer and use it in GitHub Desktop.
Save taurenshaman/ed4dfd5019ade10e78a2dbacf24ac955 to your computer and use it in GitHub Desktop.
pw-core/src/signers/blake2b-signer.ts
import { Signer, Message } from '.';
import { Blake2bHasher } from '../hashers';
import { Provider } from '../providers';
export class Blake2bSigner extends Signer {
constructor(public readonly provider: Provider, key: string = null) {
super(new Blake2bHasher(key));
}
signMessage(message: string): Promise<string>{
return this.provider.sign(message);
}
async signMessages(messages: Message[]): Promise<string[]> {
const sigs = [];
for (const message of messages) {
if (
this.provider.address.toLockScript().toHash() === message.lock.toHash()
) {
sigs.push(await this.provider.sign(message.message));
} else {
sigs.push('0x');
}
}
return sigs;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment