mirror of
https://github.com/selfxyz/self.git
synced 2026-02-08 13:25:59 -05:00
clean
This commit is contained in:
@@ -80,6 +80,15 @@ const md = forge.md.sha256.create();
|
||||
md.update(forge.util.binary.raw.encode(new Uint8Array(eContent)));
|
||||
const hashOfEContent = md.digest().getBytes();
|
||||
|
||||
console.log('modulus', hexToDecimal(modulus));
|
||||
console.log('eContent', bytesToBigDecimal(passportData.eContent));
|
||||
console.log('signature', bytesToBigDecimal(passportData.encryptedDigest));
|
||||
// Convert the hash to a single decimal number
|
||||
|
||||
const hashBigNumber = BigInt('0x' + forge.util.bytesToHex(hashOfEContent));
|
||||
|
||||
console.log('hashOfEContent in big decimal', hashBigNumber.toString());
|
||||
|
||||
// Signature verification
|
||||
const signatureBytes = Buffer.from(passportData.encryptedDigest).toString(
|
||||
'binary',
|
||||
@@ -97,3 +106,15 @@ function hash(bytesArray: number[]): number[] {
|
||||
hash.update(Buffer.from(bytesArray));
|
||||
return Array.from(hash.digest()).map(x => (x < 128 ? x : x - 256));
|
||||
}
|
||||
|
||||
function bytesToBigDecimal(arr: number[]): string {
|
||||
let result = BigInt(0);
|
||||
for (let i = 0; i < arr.length; i++) {
|
||||
result = result * BigInt(256) + BigInt(arr[i] & 0xff);
|
||||
}
|
||||
return result.toString();
|
||||
}
|
||||
|
||||
function hexToDecimal(hex: string): string {
|
||||
return BigInt(`0x${hex}`).toString();
|
||||
}
|
||||
|
||||
@@ -89,8 +89,8 @@ export function parsePubKeyString(pubKeyString: string) {
|
||||
const modulus = modulusMatch ? modulusMatch[1] : null;
|
||||
const exponent = publicExponentMatch ? publicExponentMatch[1] : null;
|
||||
|
||||
console.log('Modulus:', modulus);
|
||||
console.log('Public Exponent:', exponent);
|
||||
// console.log('Modulus:', modulus);
|
||||
// console.log('Public Exponent:', exponent);
|
||||
|
||||
if (!modulus || !exponent) {
|
||||
throw new Error('Could not parse public key string');
|
||||
|
||||
Reference in New Issue
Block a user