@cipherstash/ore-rs
Advanced tools
Comparing version 0.2.1 to 0.2.2
@@ -10,4 +10,36 @@ /// <reference types="node" /> | ||
export interface ORE { | ||
/** | ||
* Converts a string to a ORE-compatible plaintext (a JS number). The number | ||
* is the siphash of the string. | ||
* | ||
* Ciphertexts made from the plaintext can only be meaningfully checked for | ||
* equality. In the medium term we will use an equality revealing scheme for | ||
* strings. | ||
* | ||
* @param input the JS string to encode | ||
* @returns a JS number that can be encrypted with the ORE scheme | ||
*/ | ||
encodeString: (input: string) => number; | ||
/** | ||
* Prepares a plaintext (a JS number AKA f64) for ORE encryption by converting | ||
* to an orderable integer (u64). The orderable integer is returned as a JS | ||
* number which will be different to the input plaintext and should be treated | ||
* as an opaque value. | ||
* | ||
* @param input the JS number to encode | ||
* @returns a JS number that can be encrypted with the ORE scheme | ||
*/ | ||
encodeNumber: (input: number) => number; | ||
/** | ||
* Converts an 8 byte buffer containing a 64 bit unsigned integer into an | ||
* ORE-compatible plaintext (a JS number). | ||
* | ||
* @param input the JS buffer to encode | ||
* @returns a JS number that can be encrypted with the ORE scheme | ||
*/ | ||
encodeBuffer: (input: Buffer) => number; | ||
/** | ||
* Initialize a new ORE cipher with a key pair (both keys must be 16-byte | ||
* buffers) | ||
*/ | ||
init: (k1: Key, k2: Key) => ORECipher; | ||
@@ -14,0 +46,0 @@ compare: (a: CipherText, b: CipherText) => Ordering; |
@@ -5,3 +5,3 @@ "use strict"; | ||
/* Importing the rust compiled lib (index.node) doesn't work and so we use require here */ | ||
const { initCipher, encrypt, encryptLeft, compare, encodeNumber, encodeString } = require("../index.node"); | ||
const { initCipher, encrypt, encryptLeft, compare, encodeNumber, encodeString, encodeBuffer } = require("../index.node"); | ||
/** | ||
@@ -12,49 +12,14 @@ * Module to perform Order-revealing Encryption using the underlying ore.rs Rust | ||
exports.ORE = { | ||
/** | ||
* Prepares a plaintext (a JS number AKA f64) for ORE encryption by converting | ||
* to an orderable integer (u64). The orderable integer is returned as a JS | ||
* number which will be different to the input plaintext and should be treated | ||
* as an opaque value. | ||
* | ||
* @param input the JS number to encode | ||
* @returns a JS number that can be encrypted with the ORE scheme | ||
*/ | ||
encodeNumber, | ||
/** | ||
* Converts a string to a ORE-compatible plaintext (a JS number). The number | ||
* is the siphash of the string. | ||
* | ||
* Ciphertexts made from the plaintext can only be meaningfully checked for | ||
* equality. In the medium term we will use an equality revealing scheme for | ||
* strings. | ||
* | ||
* @param input the JS number to encode | ||
* @returns a JS number that can be encrypted with the ORE scheme | ||
*/ | ||
encodeString, | ||
/** | ||
* Initialize a new ORE cipher with a key pair (both keys must be 16-byte | ||
* buffers) | ||
*/ | ||
encodeBuffer, | ||
init: (k1, k2) => { | ||
let cipher = initCipher(k1, k2); | ||
return { | ||
/* | ||
* Encrypt the given `PlainText` outputting a "full" CipherText (i.e. a | ||
* `Buffer` containing both the Left and Right components). | ||
*/ | ||
encrypt: (input) => encrypt(cipher, input), | ||
/* | ||
* Encrypt the given `PlainText` outputting only a Left CipherText (i.e. a | ||
* `Buffer` containing just the Left component). | ||
*/ | ||
encryptLeft: (input) => encryptLeft(cipher, input) | ||
}; | ||
}, | ||
/* | ||
* Compare two cipher texts returning -1 if a < b, 0 if a === b, and 1 if a > | ||
* b. Throws if the inputs are not comparable. | ||
*/ | ||
compare: (a, b) => compare(a, b) | ||
}; | ||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi9zcmMvaW5kZXgudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7O0FBQUEsMEZBQTBGO0FBQzFGLE1BQU0sRUFDSixVQUFVLEVBQ1YsT0FBTyxFQUNQLFdBQVcsRUFDWCxPQUFPLEVBQ1AsWUFBWSxFQUNaLFlBQVksRUFDYixHQUFHLE9BQU8sQ0FBQyxlQUFlLENBQUMsQ0FBQTtBQW1CNUI7OztHQUdHO0FBQ1UsUUFBQSxHQUFHL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ID0+IGVuY3J5cHQoY2lwaGVyLCBpbnB1dCksXG5cbiAgICAgIGVuY3J5cHRMZWZ0OiAoaW5wdXQ6IG51bWJlcik6IENpcGhlclRleHQgPT4gZW5jcnlwdExlZnQoY2lwaGVyLCBpbnB1dClcbiAgICB9XG4gIH0sXG5cbiAgY29tcGFyZTogKGE6IENpcGhlclRleHQsIGI6IENpcGhlclRleHQpOiBPcmRlcmluZyA9PiBjb21wYXJlKGEsIGIpXG59XG4iXX0= |
{ | ||
"name": "@cipherstash/ore-rs", | ||
"version": "0.2.1", | ||
"version": "0.2.2", | ||
"description": "Node bindings for ore.rs", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -8,3 +8,4 @@ /* Importing the rust compiled lib (index.node) doesn't work and so we use require here */ | ||
encodeNumber, | ||
encodeString | ||
encodeString, | ||
encodeBuffer | ||
} = require("../index.node") | ||
@@ -16,3 +17,12 @@ | ||
export type ORECipher = { | ||
/* | ||
* Encrypt the given `PlainText` outputting a "full" CipherText (i.e. a | ||
* `Buffer` containing both the Left and Right components). | ||
*/ | ||
encrypt: (input: number) => CipherText, | ||
/* | ||
* Encrypt the given `PlainText` outputting only a Left CipherText (i.e. a | ||
* `Buffer` containing just the Left component). | ||
*/ | ||
encryptLeft: (input: number) => CipherText | ||
@@ -24,14 +34,15 @@ } | ||
export interface ORE { | ||
/** | ||
* Converts a string to a ORE-compatible plaintext (a JS number). The number | ||
* is the siphash of the string. | ||
* | ||
* Ciphertexts made from the plaintext can only be meaningfully checked for | ||
* equality. In the medium term we will use an equality revealing scheme for | ||
* strings. | ||
* | ||
* @param input the JS string to encode | ||
* @returns a JS number that can be encrypted with the ORE scheme | ||
*/ | ||
encodeString: (input: string) => number | ||
encodeNumber: (input: number) => number | ||
init: (k1: Key, k2: Key) => ORECipher | ||
compare: (a: CipherText, b: CipherText) => Ordering | ||
} | ||
/** | ||
* Module to perform Order-revealing Encryption using the underlying ore.rs Rust | ||
* library. | ||
*/ | ||
export const ORE: ORE = { | ||
/** | ||
@@ -46,16 +57,12 @@ * Prepares a plaintext (a JS number AKA f64) for ORE encryption by converting | ||
*/ | ||
encodeNumber, | ||
encodeNumber: (input: number) => number | ||
/** | ||
* Converts a string to a ORE-compatible plaintext (a JS number). The number | ||
* is the siphash of the string. | ||
* Converts an 8 byte buffer containing a 64 bit unsigned integer into an | ||
* ORE-compatible plaintext (a JS number). | ||
* | ||
* Ciphertexts made from the plaintext can only be meaningfully checked for | ||
* equality. In the medium term we will use an equality revealing scheme for | ||
* strings. | ||
* | ||
* @param input the JS number to encode | ||
* @param input the JS buffer to encode | ||
* @returns a JS number that can be encrypted with the ORE scheme | ||
*/ | ||
encodeString, | ||
encodeBuffer: (input: Buffer) => number | ||
@@ -66,15 +73,28 @@ /** | ||
*/ | ||
init: (k1: Key, k2: Key) => ORECipher | ||
/* | ||
* Compare two cipher texts returning -1 if a < b, 0 if a === b, and 1 if a > | ||
* b. Throws if the inputs are not comparable. | ||
*/ | ||
compare: (a: CipherText, b: CipherText) => Ordering | ||
} | ||
/** | ||
* Module to perform Order-revealing Encryption using the underlying ore.rs Rust | ||
* library. | ||
*/ | ||
export const ORE: ORE = { | ||
encodeNumber, | ||
encodeString, | ||
encodeBuffer, | ||
init: (k1: Key, k2: Key): ORECipher => { | ||
let cipher = initCipher(k1, k2); | ||
return { | ||
/* | ||
* Encrypt the given `PlainText` outputting a "full" CipherText (i.e. a | ||
* `Buffer` containing both the Left and Right components). | ||
*/ | ||
encrypt: (input: number): CipherText => encrypt(cipher, input), | ||
/* | ||
* Encrypt the given `PlainText` outputting only a Left CipherText (i.e. a | ||
* `Buffer` containing just the Left component). | ||
*/ | ||
encryptLeft: (input: number): CipherText => encryptLeft(cipher, input) | ||
@@ -84,7 +104,3 @@ } | ||
/* | ||
* Compare two cipher texts returning -1 if a < b, 0 if a === b, and 1 if a > | ||
* b. Throws if the inputs are not comparable. | ||
*/ | ||
compare: (a: CipherText, b: CipherText): Ordering => compare(a, b) | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
117514
477