Created
March 5, 2021 06:43
-
-
Save taurenshaman/ed4dfd5019ade10e78a2dbacf24ac955 to your computer and use it in GitHub Desktop.
pw-core/src/signers/blake2b-signer.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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