Package org.protelis.vm.impl
Class HashingCodePathFactory
- java.lang.Object
-
- org.protelis.vm.impl.HashingCodePathFactory
-
- All Implemented Interfaces:
java.io.Serializable,CodePathFactory
public class HashingCodePathFactory extends java.lang.Object implements CodePathFactory
A hash-basedCodePathfactory. It allows for predictable packet sizes, as codepath length is no affected by the evaluation tree depth at which the field was built. It is arguably more secure than the default option (if a cryptographic hashing function is used) as receivers cannot deduce the code that generated some values. The provided factory is configurable by using anHashFunctionfrom Guava. Being hash based, it has a non-zero probability of collision. Using decent hash functions (e.g. SHA) should however make the event very unlikely. In any case, there is a trade-off between collision probability and packet size. Implementations ofAbstractExecutionContextcan use it by passing the factory instance in the super constructor call, e.g.:super(execenv, netmgr, new HashingCodePathFactory(Hashing.sha256()));
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceHashingCodePathFactory.HasherSupplierSerializable supplier, because Java 8 lambdas are not.static classHashingCodePathFactory.HashingCodePathHash-basedCodePath.
-
Constructor Summary
Constructors Constructor Description HashingCodePathFactory(com.google.common.hash.HashFunction hashFunction)HashingCodePathFactory(HashingCodePathFactory.HasherSupplier hashFunction)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description CodePathcreateCodePath(gnu.trove.list.TIntList callStackIdentifiers, gnu.trove.stack.TIntStack callStackSizes)Creates aCodePathfor the current stack status.
-
-
-
Constructor Detail
-
HashingCodePathFactory
public HashingCodePathFactory(HashingCodePathFactory.HasherSupplier hashFunction)
- Parameters:
hashFunction- the hashing algorithm to use
-
HashingCodePathFactory
public HashingCodePathFactory(com.google.common.hash.HashFunction hashFunction)
- Parameters:
hashFunction- the hashing algorithm to use
-
-
Method Detail
-
createCodePath
public final CodePath createCodePath(gnu.trove.list.TIntList callStackIdentifiers, gnu.trove.stack.TIntStack callStackSizes)
Description copied from interface:CodePathFactoryCreates aCodePathfor the current stack status.- Specified by:
createCodePathin interfaceCodePathFactory- Parameters:
callStackIdentifiers- the stack frames identifierscallStackSizes- the stack frame sizes, by frame- Returns:
- a new
CodePath
-
-