mirror of
https://github.com/signalapp/libsignal.git
synced 2026-04-26 01:35:22 +02:00
Expose PniCredential operations to app languages
This commit is contained in:
@@ -9,11 +9,16 @@ import { RANDOM_LENGTH } from '../internal/Constants';
|
||||
import * as Native from '../../../Native';
|
||||
|
||||
import ServerPublicParams from '../ServerPublicParams';
|
||||
import ProfileKeyCredentialRequestContext from './ProfileKeyCredentialRequestContext';
|
||||
import GroupSecretParams from '../groups/GroupSecretParams';
|
||||
|
||||
import PniCredential from './PniCredential';
|
||||
import PniCredentialPresentation from './PniCredentialPresentation';
|
||||
import PniCredentialRequestContext from './PniCredentialRequestContext';
|
||||
import PniCredentialResponse from './PniCredentialResponse';
|
||||
import ProfileKey from './ProfileKey';
|
||||
import ProfileKeyCredential from './ProfileKeyCredential';
|
||||
import ProfileKeyCredentialPresentation from './ProfileKeyCredentialPresentation';
|
||||
import GroupSecretParams from '../groups/GroupSecretParams';
|
||||
import ProfileKeyCredentialRequestContext from './ProfileKeyCredentialRequestContext';
|
||||
import ProfileKeyCredentialResponse from './ProfileKeyCredentialResponse';
|
||||
|
||||
import { UUIDType, fromUUID } from '../internal/UUIDUtil';
|
||||
@@ -53,6 +58,38 @@ export default class ClientZkProfileOperations {
|
||||
);
|
||||
}
|
||||
|
||||
createPniCredentialRequestContext(
|
||||
aci: UUIDType,
|
||||
pni: UUIDType,
|
||||
profileKey: ProfileKey
|
||||
): PniCredentialRequestContext {
|
||||
const random = randomBytes(RANDOM_LENGTH);
|
||||
|
||||
return this.createPniCredentialRequestContextWithRandom(
|
||||
random,
|
||||
aci,
|
||||
pni,
|
||||
profileKey
|
||||
);
|
||||
}
|
||||
|
||||
createPniCredentialRequestContextWithRandom(
|
||||
random: Buffer,
|
||||
aci: UUIDType,
|
||||
pni: UUIDType,
|
||||
profileKey: ProfileKey
|
||||
): PniCredentialRequestContext {
|
||||
return new PniCredentialRequestContext(
|
||||
Native.ServerPublicParams_CreatePniCredentialRequestContextDeterministic(
|
||||
this.serverPublicParams.getContents(),
|
||||
random,
|
||||
fromUUID(aci),
|
||||
fromUUID(pni),
|
||||
profileKey.getContents()
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
receiveProfileKeyCredential(
|
||||
profileKeyCredentialRequestContext: ProfileKeyCredentialRequestContext,
|
||||
profileKeyCredentialResponse: ProfileKeyCredentialResponse
|
||||
@@ -66,6 +103,19 @@ export default class ClientZkProfileOperations {
|
||||
);
|
||||
}
|
||||
|
||||
receivePniCredential(
|
||||
requestContext: PniCredentialRequestContext,
|
||||
response: PniCredentialResponse
|
||||
): PniCredential {
|
||||
return new PniCredential(
|
||||
Native.ServerPublicParams_ReceivePniCredential(
|
||||
this.serverPublicParams.getContents(),
|
||||
requestContext.getContents(),
|
||||
response.getContents()
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
createProfileKeyCredentialPresentation(
|
||||
groupSecretParams: GroupSecretParams,
|
||||
profileKeyCredential: ProfileKeyCredential
|
||||
@@ -93,4 +143,32 @@ export default class ClientZkProfileOperations {
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
createPniCredentialPresentation(
|
||||
groupSecretParams: GroupSecretParams,
|
||||
credential: PniCredential
|
||||
): PniCredentialPresentation {
|
||||
const random = randomBytes(RANDOM_LENGTH);
|
||||
|
||||
return this.createPniCredentialPresentationWithRandom(
|
||||
random,
|
||||
groupSecretParams,
|
||||
credential
|
||||
);
|
||||
}
|
||||
|
||||
createPniCredentialPresentationWithRandom(
|
||||
random: Buffer,
|
||||
groupSecretParams: GroupSecretParams,
|
||||
credential: PniCredential
|
||||
): PniCredentialPresentation {
|
||||
return new PniCredentialPresentation(
|
||||
Native.ServerPublicParams_CreatePniCredentialPresentationDeterministic(
|
||||
this.serverPublicParams.getContents(),
|
||||
random,
|
||||
groupSecretParams.getContents(),
|
||||
credential.getContents()
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user