-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
620b755
commit d4a2d0c
Showing
55 changed files
with
352 additions
and
1,244 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,5 +14,4 @@ examples/*/pnpm-lock.yaml | |
pnpm-debug.log | ||
docs-json | ||
./docs | ||
.env | ||
.next |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'; |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.