How to use the eosjs.Numeric.signatureToString function in eosjs

To help you get started, we’ve selected a few eosjs examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github EOSIO / eosio-webauthn-example-app / src / client / wasig.ts View on Github external
const s = fixup(der.getUint8Array(der.get()));

            const whatItReallySigned = new Serialize.SerialBuffer();
            whatItReallySigned.pushArray(new Uint8Array(assertion.response.authenticatorData));
            whatItReallySigned.pushArray(new Uint8Array(await crypto.subtle.digest('SHA-256', assertion.response.clientDataJSON)));
            const hash = new Uint8Array(await crypto.subtle.digest('SHA-256', whatItReallySigned.asUint8Array().slice()));
            const recid = e.getKeyRecoveryParam(hash, new Uint8Array(assertion.response.signature), pubKey);

            const sigData = new Serialize.SerialBuffer();
            sigData.push(recid + 27 + 4);
            sigData.pushArray(r);
            sigData.pushArray(s);
            sigData.pushBytes(new Uint8Array(assertion.response.authenticatorData));
            sigData.pushBytes(new Uint8Array(assertion.response.clientDataJSON));

            const sig = Numeric.signatureToString({
                type: Numeric.KeyType.wa,
                data: sigData.asUint8Array().slice(),
            });
            signatures.push(sig);
        }
        return { signatures, serializedTransaction, serializedContextFreeData };
    }
}