/// <summary> /// Calculate the ChaCha Hash of the given 512-bit state. /// </summary> /// <param name="state">The state which will be hashed</param> /// <param name="rounds">Rounds of hash function</param> private void ChaChaHash(ref uint[] state, int rounds) { if (!(rounds == 8 || rounds == 12 || rounds == 20)) { throw new ArgumentException("Rounds must be 8, 12 or 20."); } // The original state before ChaCha hash function was applied. Needed for state addition afterwards. uint[] originalState = (uint[])state.Clone(); OriginalState.Add(originalState); for (int i = 0; i < rounds / 2; ++i) { // Column rounds Quarterround(ref state, 0, 4, 8, 12); Quarterround(ref state, 1, 5, 9, 13); Quarterround(ref state, 2, 6, 10, 14); Quarterround(ref state, 3, 7, 11, 15); // Diagonal rounds Quarterround(ref state, 0, 5, 10, 15); Quarterround(ref state, 1, 6, 11, 12); Quarterround(ref state, 2, 7, 8, 13); Quarterround(ref state, 3, 4, 9, 14); } AdditionStep(ref state, originalState); LittleEndianStep(ref state); }
public InteractableData(XRManipulableInteractable interactable) { this.interactable = interactable; originalState = new OriginalState ( interactable.transform.position, interactable.transform.localPosition, interactable.transform.localScale, interactable.transform.rotation ); }
private void OnInteractableSelectEnter(XRBaseInteractor interactor) { isSelected = true; if (interactor.selectTarget.GetType() != typeof(XRManipulableInteractable)) { return; } if (currentInteractable.interactable == null) { currentInteractable = new InteractableData((XRManipulableInteractable)interactor.selectTarget); originalState = new OriginalState(transform.position, transform.localPosition, transform.localScale, transform.rotation); CreateManipulableCopy(); } }
public void RecordChanges(BulkDescriptor bulk) { var originalDict = OriginalState.ToDictionary(); var currentDict = CurrentState.ToDictionary(); var correlation = currentDict.CorrelateWith(originalDict); // Ensure all of the current ones have changes recorded foreach (var tuple in correlation.SourceItems) { RecordChanges(tuple.Item, tuple.PairedWith, bulk); } // Remove anything no longer current foreach (var aspect in correlation.NonSourceItems.SelectMany(s => s.Item.Aspects.Values)) { aspect.RemoveAll(bulk); } }
private void ClearIntermediateResults() { // matrices OriginalState.Clear(); OriginalStateDiffusion.Clear(); AdditionResultState.Clear(); AdditionResultStateDiffusion.Clear(); LittleEndianState.Clear(); LittleEndianStateDiffusion.Clear(); // qr QRInput.Clear(); QRInputDiffusion.Clear(); QRStep.Clear(); QRStepDiffusion.Clear(); QROutput.Clear(); QROutputDiffusion.Clear(); InputMessage.Clear(); Keystream.Clear(); KeystreamDiffusion.Clear(); Output.Clear(); OutputDiffusion.Clear(); }
public void Rollback() { OriginalState.Reset(Actor); }
public InteractableData() { interactable = null; originalState = new OriginalState(); }