Package pygar.zoneable
Class NumberConceal
java.lang.Object
pygar.zoneable.NumberConceal
@ThreadSafe public class NumberConceal extends java.lang.Object
-
Constructor Summary
Constructors Constructor Description NumberConceal(javax.crypto.Cipher crypto, java.lang.String key, int nsegments, double number_min, double number_max, double number_range)
Instances of this class provide a method to conceal the value of real numbers using a piecewise linear mapping that is unique to the value's name. -
Method Summary
Modifier and Type Method Description void
addName(java.lang.String name, double value_min, double value_max)
Add the name of a value that will later be concealed by the conceal functiondouble
conceal(java.lang.String name, double value)
Conceal a named value.java.lang.String
encodeString(java.lang.String s)
boolean
hasName(java.lang.String name)
Check whether a value name is defined already.double
reveal(java.lang.String name, double value)
-
Constructor Details
-
NumberConceal
public NumberConceal(javax.crypto.Cipher crypto, java.lang.String key, int nsegments, double number_min, double number_max, double number_range)Instances of this class provide a method to conceal the value of real numbers using a piecewise linear mapping that is unique to the value's name. The mapping function is derived by encrypting the value name and converting the encrypted value into a numeric function. The value of nsegments has practical constaints. If nsegments is too small, the algorithm as implemented here will attempt to convert a string as a hexidecimal number that is too large for the Java converter. In the other direction, nsegments cannot be larger than the number of bytes in the encryption algorithm's block size. Neither of these number has a convenient, universal name, so we don't currently check the limits. During testing, the algorithm worked well for nsegments >= 4 and <= 32. Moreover, we only verified the powers of two: 4, 8, 16, 32.- Parameters:
nsegments
- the number of linear segments in the piecewise linear functionkey
- the encryption key used to derive the function from a namenumber_min
- the most negative value that can be represented enterprise widenumber_max
- the most positive value that can be represented enterprise widenumber_range
- the agreed range of numerical representation which should be less than cmax-cmin
-
-
Method Details
-
conceal
Conceal a named value.- Parameters:
name
-value
-- Returns:
- the concealed value
- Throws:
ConfigurationError
-
reveal
- Throws:
ConfigurationError
-
addName
public void addName(java.lang.String name, double value_min, double value_max) throws ConfigurationError, CryptoExceptionAdd the name of a value that will later be concealed by the conceal function- Parameters:
name
- name of the valuevalue_min
- smallest value expected for the named valuevalue_max
- largest value expected for the named value- Throws:
ConfigurationError
CryptoException
-
hasName
public boolean hasName(java.lang.String name)Check whether a value name is defined already.- Parameters:
name
- name of a value- Returns:
- true if the name is defined
-
encodeString
- Throws:
CryptoException
-