1- import { schnorr } from '@noble/curves/secp256k1'
2- import { sha256 } from '@noble/hashes/sha256'
3- import { bytesToHex } from '@noble/hashes/utils'
1+ import { schnorr } from '@noble/curves/secp256k1'
2+ import { sha256 } from '@noble/hashes/sha256'
3+ import { bytesToHex } from '@noble/hashes/utils'
44
55// import {utf8Encoder} from './utils'
6- import { getPublicKey } from './keys'
6+ import { getPublicKey } from './keys'
77
88export const utf8Decoder = new TextDecoder ( 'utf-8' )
99export const utf8Encoder = new TextEncoder ( )
@@ -58,7 +58,7 @@ export type Msg = UnsignedMsg & {
5858 }
5959} */
6060
61- export function finishMsg ( t : MsgTemplate , privateKey : string ) : Message {
61+ export function finishMsg ( t : MsgTemplate , privateKey : string ) : Message {
6262 // to update to chat message triples
6363 let message = t as Message
6464 // message.pubkey = getPublicKey(privateKey)
@@ -67,7 +67,7 @@ export function finishMsg(t: MsgTemplate, privateKey: string): Message {
6767 return message
6868}
6969
70- export function serializeMsg ( msg : UnsignedMsg ) : string {
70+ export function serializeMsg ( msg : UnsignedMsg ) : string {
7171 // to update to chat messages triples
7272 /* if (!validateMsg(msg))
7373 throw new Error("can't serialize message with wrong or missing properties") */
@@ -82,7 +82,7 @@ export function serializeMsg(msg: UnsignedMsg): string {
8282 ] )
8383}
8484
85- export function getMsgHash ( message : UnsignedMsg ) : string {
85+ export function getMsgHash ( message : UnsignedMsg ) : string {
8686 let msgHash = sha256 ( utf8Encoder . encode ( serializeMsg ( message ) ) )
8787 return bytesToHex ( msgHash )
8888}
@@ -109,16 +109,16 @@ const isRecord = (obj: unknown): obj is Record<string, unknown> => obj instanceo
109109 return true
110110} */
111111
112- export function verifySignature ( message : Message ) : boolean {
112+ export function verifySignature ( message : Message ) : boolean {
113113 return schnorr . verify (
114114 message . sig ,
115- getMsgHash ( message ) ,
115+ getMsgHash ( message )
116116 // message.pubkey
117117 )
118118}
119119
120- export function signMsg ( message : UnsignedMsg , key : string ) : string {
120+ export function signMsg ( message : UnsignedMsg , key : string ) : string {
121121 return bytesToHex (
122122 schnorr . sign ( getMsgHash ( message ) , key )
123123 )
124- }
124+ }
0 commit comments