Sha256: 1bdafd6308f06bc8c0b0c91bfeb649413f113748d72b7688392c27584977ea4d
Contents?: true
Size: 1.27 KB
Versions: 1
Compression:
Stored size: 1.27 KB
Contents
/** * @module index */ import {base58Encode, blake2b, concat, signBytes, address} from '@waves/ts-lib-crypto' import {serializePrimitives} from '@waves/marshall' const {LONG, BASE58_STRING} = serializePrimitives import {getSenderPublicKey, convertToPairs} from '../generic' import {IWavesAuthParams, IWavesAuth} from '../transactions' import {validate} from '../validators' import {TSeedTypes} from '../types' export const serializeWavesAuthData = (auth: { publicKey: string; timestamp: number }) => concat( BASE58_STRING(auth.publicKey), LONG(auth.timestamp) ) export function wavesAuth(params: IWavesAuthParams, seed?: TSeedTypes, chainId?: string | number): IWavesAuth { const seedsAndIndexes = convertToPairs(seed) const publicKey = params.publicKey || getSenderPublicKey(seedsAndIndexes, {senderPublicKey: undefined}) const timestamp = params.timestamp || Date.now() validate.wavesAuth({publicKey, timestamp}) const rx = { hash: '', signature: '', timestamp, publicKey, address: address({publicKey}, chainId), } const bytes = serializeWavesAuthData(rx) rx.signature = seedsAndIndexes.map(([seed]) => signBytes(seed, bytes))[0] || '' rx.hash = base58Encode(blake2b(Uint8Array.from(bytes))) return rx }
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
waves_lib-0.1.0 | js/node_modules/@waves/waves-transactions/src/requests/wavesAuth.ts |