Skip to content

Commit

Permalink
feat!: deprecate pre-tdec
Browse files Browse the repository at this point in the history
  • Loading branch information
piotr-roslaniec committed Oct 5, 2023
1 parent 620b755 commit d4a2d0c
Show file tree
Hide file tree
Showing 55 changed files with 352 additions and 1,244 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,4 @@ examples/*/pnpm-lock.yaml
pnpm-debug.log
docs-json
./docs
.env
.next
21 changes: 4 additions & 17 deletions packages/pre/src/characters/enrico.ts
Original file line number Diff line number Diff line change
@@ -1,39 +1,26 @@
import { MessageKit, PublicKey, SecretKey } from '@nucypher/nucypher-core';
import { ConditionExpression, toBytes } from '@nucypher/shared';
import { toBytes } from '@nucypher/shared';

import { Keyring } from '../keyring';

export class Enrico {
public readonly encryptingKey: PublicKey;
private readonly keyring: Keyring;
public conditions?: ConditionExpression | undefined;

constructor(
encryptingKey: PublicKey,
verifyingKey?: SecretKey,
conditions?: ConditionExpression,
) {
constructor(encryptingKey: PublicKey, verifyingKey?: SecretKey) {
this.encryptingKey = encryptingKey;
this.keyring = new Keyring(verifyingKey ?? SecretKey.random());
this.conditions = conditions;
}

public get verifyingKey(): PublicKey {
return this.keyring.publicKey;
}

public encryptMessagePre(
plaintext: Uint8Array | string,
withConditions?: ConditionExpression,
): MessageKit {
if (!withConditions) {
withConditions = this.conditions;
}

public encryptMessage(plaintext: Uint8Array | string): MessageKit {
return new MessageKit(
this.encryptingKey,
plaintext instanceof Uint8Array ? plaintext : toBytes(plaintext),
withConditions ? withConditions.toWASMConditions() : null,
null,
);
}
}
1 change: 0 additions & 1 deletion packages/pre/src/characters/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
export * from './alice';
export * from './bob';
export * from './enrico';
export * from './pre-recipient';
210 changes: 0 additions & 210 deletions packages/pre/src/characters/pre-recipient.ts

This file was deleted.

4 changes: 1 addition & 3 deletions packages/shared/src/cohort.ts → packages/pre/src/cohort.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import { PorterClient } from './porter';
import { ChecksumAddress } from './types';
import { objectEquals } from './utils';
import { ChecksumAddress, objectEquals, PorterClient } from '@nucypher/shared';

export type CohortJSON = {
ursulaAddresses: ChecksumAddress[];
Expand Down
8 changes: 2 additions & 6 deletions packages/pre/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
export {
Cohort,
PorterClient,
conditions,
fromHexString,
getPorterUri,
toBytes,
Expand All @@ -20,8 +18,6 @@ export {
initialize,
} from '@nucypher/nucypher-core';

export { DeployedPreStrategy, PreStrategy } from './pre-strategy';

export { Alice, Bob, PreDecrypter } from './characters';

export { Alice, Bob, Enrico } from './characters';
export { Cohort } from './cohort';
export { EnactedPolicy } from './policy';
2 changes: 1 addition & 1 deletion packages/pre/src/policy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ export class BlockchainPolicy {
public async generatePreEnactedPolicy(
ursulas: readonly Ursula[],
): Promise<PreEnactedPolicy> {
if (ursulas.length != this.verifiedKFrags.length) {
if (ursulas.length !== this.verifiedKFrags.length) {
throw new Error(
`Number of ursulas must match number of verified kFrags: ${this.verifiedKFrags.length}`,
);
Expand Down
Loading

0 comments on commit d4a2d0c

Please sign in to comment.