"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "ts/util/zkgroup.ts" between
Signal-Desktop-1.35.2.tar.gz and Signal-Desktop-1.36.1.tar.gz

About: Signal-Desktop is a cross-platform encrypted messaging service (also available for mobile devices).

zkgroup.ts  (Signal-Desktop-1.35.2):zkgroup.ts  (Signal-Desktop-1.36.1)
export * from 'zkgroup'; export * from 'zkgroup';
import { import {
AuthCredential,
ClientZkAuthOperations,
ClientZkGroupCipher,
ClientZkProfileOperations, ClientZkProfileOperations,
FFICompatArray, FFICompatArray,
FFICompatArrayType, FFICompatArrayType,
GroupMasterKey,
GroupSecretParams,
ProfileKey, ProfileKey,
ProfileKeyCiphertext,
ProfileKeyCredentialPresentation,
ProfileKeyCredentialRequestContext, ProfileKeyCredentialRequestContext,
ProfileKeyCredentialResponse, ProfileKeyCredentialResponse,
ServerPublicParams, ServerPublicParams,
UuidCiphertext,
} from 'zkgroup'; } from 'zkgroup';
import { import {
arrayBufferToBase64, arrayBufferToBase64,
arrayBufferToHex, arrayBufferToHex,
base64ToArrayBuffer, base64ToArrayBuffer,
typedArrayToArrayBuffer, typedArrayToArrayBuffer,
} from '../Crypto'; } from '../Crypto';
// Simple utility functions
export function arrayBufferToCompatArray( export function arrayBufferToCompatArray(
arrayBuffer: ArrayBuffer arrayBuffer: ArrayBuffer
): FFICompatArrayType { ): FFICompatArrayType {
const buffer = Buffer.from(arrayBuffer); const buffer = Buffer.from(arrayBuffer);
return new FFICompatArray(buffer); return new FFICompatArray(buffer);
} }
export function compatArrayToArrayBuffer( export function compatArrayToArrayBuffer(
compatArray: FFICompatArrayType compatArray: FFICompatArrayType
skipping to change at line 45 skipping to change at line 55
} }
export function compatArrayToBase64(compatArray: FFICompatArrayType): string { export function compatArrayToBase64(compatArray: FFICompatArrayType): string {
return arrayBufferToBase64(compatArrayToArrayBuffer(compatArray)); return arrayBufferToBase64(compatArrayToArrayBuffer(compatArray));
} }
export function compatArrayToHex(compatArray: FFICompatArrayType): string { export function compatArrayToHex(compatArray: FFICompatArrayType): string {
return arrayBufferToHex(compatArrayToArrayBuffer(compatArray)); return arrayBufferToHex(compatArrayToArrayBuffer(compatArray));
} }
// Scenarios
export function decryptGroupBlob(
clientZkGroupCipher: ClientZkGroupCipher,
ciphertext: ArrayBuffer
) {
return compatArrayToArrayBuffer(
clientZkGroupCipher.decryptBlob(arrayBufferToCompatArray(ciphertext))
);
}
export function decryptProfileKeyCredentialPresentation(
clientZkGroupCipher: ClientZkGroupCipher,
presentationBuffer: ArrayBuffer
): { profileKey: ArrayBuffer; uuid: string } {
const presentation = new ProfileKeyCredentialPresentation(
arrayBufferToCompatArray(presentationBuffer)
);
const uuidCiphertext = presentation.getUuidCiphertext();
const uuid = clientZkGroupCipher.decryptUuid(uuidCiphertext);
const profileKeyCiphertext = presentation.getProfileKeyCiphertext();
const profileKey = clientZkGroupCipher.decryptProfileKey(
profileKeyCiphertext,
uuid
);
return {
profileKey: compatArrayToArrayBuffer(profileKey.serialize()),
uuid,
};
}
export function decryptProfileKey(
clientZkGroupCipher: ClientZkGroupCipher,
profileKeyCiphertextBuffer: ArrayBuffer,
uuid: string
): ArrayBuffer {
const profileKeyCiphertext = new ProfileKeyCiphertext(
arrayBufferToCompatArray(profileKeyCiphertextBuffer)
);
const profileKey = clientZkGroupCipher.decryptProfileKey(
profileKeyCiphertext,
uuid
);
return compatArrayToArrayBuffer(profileKey.serialize());
}
export function decryptUuid(
clientZkGroupCipher: ClientZkGroupCipher,
uuidCiphertextBuffer: ArrayBuffer
): string {
const uuidCiphertext = new UuidCiphertext(
arrayBufferToCompatArray(uuidCiphertextBuffer)
);
return clientZkGroupCipher.decryptUuid(uuidCiphertext);
}
export function deriveProfileKeyVersion( export function deriveProfileKeyVersion(
profileKeyBase64: string, profileKeyBase64: string,
uuid: string uuid: string
) { ) {
const profileKeyArray = base64ToCompatArray(profileKeyBase64); const profileKeyArray = base64ToCompatArray(profileKeyBase64);
const profileKey = new ProfileKey(profileKeyArray); const profileKey = new ProfileKey(profileKeyArray);
const profileKeyVersion = profileKey.getProfileKeyVersion(uuid); const profileKeyVersion = profileKey.getProfileKeyVersion(uuid);
return profileKeyVersion.toString(); return profileKeyVersion.toString();
} }
export function getClientZkProfileOperations( export function deriveGroupPublicParams(groupSecretParamsBuffer: ArrayBuffer) {
serverPublicParamsBase64: string const groupSecretParams = new GroupSecretParams(
): ClientZkProfileOperations { arrayBufferToCompatArray(groupSecretParamsBuffer)
const serverPublicParamsArray = base64ToCompatArray(serverPublicParamsBase64); );
const serverPublicParams = new ServerPublicParams(serverPublicParamsArray);
return new ClientZkProfileOperations(serverPublicParams); return compatArrayToArrayBuffer(
groupSecretParams.getPublicParams().serialize()
);
}
export function deriveGroupID(groupSecretParamsBuffer: ArrayBuffer) {
const groupSecretParams = new GroupSecretParams(
arrayBufferToCompatArray(groupSecretParamsBuffer)
);
return compatArrayToArrayBuffer(
groupSecretParams
.getPublicParams()
.getGroupIdentifier()
.serialize()
);
}
export function deriveGroupSecretParams(
masterKeyBuffer: ArrayBuffer
): ArrayBuffer {
const masterKey = new GroupMasterKey(
arrayBufferToCompatArray(masterKeyBuffer)
);
const groupSecretParams = GroupSecretParams.deriveFromMasterKey(masterKey);
return compatArrayToArrayBuffer(groupSecretParams.serialize());
}
export function encryptGroupBlob(
clientZkGroupCipher: ClientZkGroupCipher,
plaintext: ArrayBuffer
) {
return compatArrayToArrayBuffer(
clientZkGroupCipher.encryptBlob(arrayBufferToCompatArray(plaintext))
);
}
export function encryptUuid(
clientZkGroupCipher: ClientZkGroupCipher,
uuidPlaintext: string
): ArrayBuffer {
const uuidCiphertext = clientZkGroupCipher.encryptUuid(uuidPlaintext);
return compatArrayToArrayBuffer(uuidCiphertext.serialize());
} }
export function generateProfileKeyCredentialRequest( export function generateProfileKeyCredentialRequest(
clientZkProfileCipher: ClientZkProfileOperations, clientZkProfileCipher: ClientZkProfileOperations,
uuid: string, uuid: string,
profileKeyBase64: string profileKeyBase64: string
): { context: ProfileKeyCredentialRequestContext; requestHex: string } { ): { context: ProfileKeyCredentialRequestContext; requestHex: string } {
const profileKeyArray = base64ToCompatArray(profileKeyBase64); const profileKeyArray = base64ToCompatArray(profileKeyBase64);
const profileKey = new ProfileKey(profileKeyArray); const profileKey = new ProfileKey(profileKeyArray);
skipping to change at line 87 skipping to change at line 202
); );
const request = context.getRequest(); const request = context.getRequest();
const requestArray = request.serialize(); const requestArray = request.serialize();
return { return {
context, context,
requestHex: compatArrayToHex(requestArray), requestHex: compatArrayToHex(requestArray),
}; };
} }
export function getAuthCredentialPresentation(
clientZkAuthOperations: ClientZkAuthOperations,
authCredentialBase64: string,
groupSecretParamsBase64: string
) {
const authCredential = new AuthCredential(
base64ToCompatArray(authCredentialBase64)
);
const secretParams = new GroupSecretParams(
base64ToCompatArray(groupSecretParamsBase64)
);
const presentation = clientZkAuthOperations.createAuthCredentialPresentation(
secretParams,
authCredential
);
return compatArrayToArrayBuffer(presentation.serialize());
}
export function getClientZkAuthOperations(
serverPublicParamsBase64: string
): ClientZkAuthOperations {
const serverPublicParams = new ServerPublicParams(
base64ToCompatArray(serverPublicParamsBase64)
);
return new ClientZkAuthOperations(serverPublicParams);
}
export function getClientZkGroupCipher(
groupSecretParamsBase64: string
): ClientZkGroupCipher {
const serverPublicParams = new GroupSecretParams(
base64ToCompatArray(groupSecretParamsBase64)
);
return new ClientZkGroupCipher(serverPublicParams);
}
export function getClientZkProfileOperations(
serverPublicParamsBase64: string
): ClientZkProfileOperations {
const serverPublicParams = new ServerPublicParams(
base64ToCompatArray(serverPublicParamsBase64)
);
return new ClientZkProfileOperations(serverPublicParams);
}
export function handleProfileKeyCredential( export function handleProfileKeyCredential(
clientZkProfileCipher: ClientZkProfileOperations, clientZkProfileCipher: ClientZkProfileOperations,
context: ProfileKeyCredentialRequestContext, context: ProfileKeyCredentialRequestContext,
responseBase64: string responseBase64: string
): string { ): string {
const responseArray = base64ToCompatArray(responseBase64); const response = new ProfileKeyCredentialResponse(
const response = new ProfileKeyCredentialResponse(responseArray); base64ToCompatArray(responseBase64)
);
const profileKeyCredential = clientZkProfileCipher.receiveProfileKeyCredential ( const profileKeyCredential = clientZkProfileCipher.receiveProfileKeyCredential (
context, context,
response response
); );
const credentialArray = profileKeyCredential.serialize(); const credentialArray = profileKeyCredential.serialize();
return compatArrayToBase64(credentialArray); return compatArrayToBase64(credentialArray);
} }
 End of changes. 10 change blocks. 
8 lines changed or deleted 173 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)