GE and Scalar vectors
MODIFY
WalletWasabi/Crypto/CoordinatorSecretKey.cs
WalletWasabi/Crypto/CoordinatorSecretKey.cs
@@ -24,10 +24,10 @@ namespace WalletWasabi.Crypto
public Scalar x0 { get; }
public Scalar x1 { get; }
public Scalar ya { get; }
-
public CoordinatorParameters ComputeCoordinatorParameters() =>
- new CoordinatorParameters((w * Generators.Gw + wp * Generators.Gwp),
- (x0.Negate() * Generators.Gx0) +
+ new CoordinatorParameters(
+ Cw: (w * Generators.Gw + wp * Generators.Gwp),
+ I: (x0.Negate() * Generators.Gx0) +
(x1.Negate() * Generators.Gx1) +
(ya.Negate() * Generators.Ga ) +
Generators.GV );

ADD
WalletWasabi/Crypto/GroupElementVector.cs
+using System.Collections;
+using System.Collections.Generic;
+using System.Linq;
+using WalletWasabi.Crypto.Groups;
+using WalletWasabi.Helpers;
+
+namespace WalletWasabi.Crypto
+{
+ public class GroupElementVector : IEnumerable<GroupElement>
+ {
+ public GroupElementVector(IEnumerable<GroupElement> groupElements)
+ {
+ GroupElements = groupElements.ToArray();
+ }
+
+ private IEnumerable<GroupElement> GroupElements { get; }
+
+ public IEnumerator<GroupElement> GetEnumerator() =>
+ GroupElements.GetEnumerator();
+
+ IEnumerator IEnumerable.GetEnumerator() =>
+ GetEnumerator();
+
+ public int Count => GroupElements.Count();
+
+ public GroupElement Sum() =>
+ GroupElements.Aggregate(GroupElement.Infinity, (ge, acc) => ge + acc);
+
+ public GroupElement InnerProduct(ScalarVector scalars)
+ {
+ Guard.NotNull(nameof(scalars), scalars);
+ Guard.True(nameof(scalars.Count), scalars.Count == Count);
+
+ var polynome = new GroupElementVector(
+ Enumerable
+ .Zip(scalars, GroupElements)
+ .Select( x => (s: x.First, G: x.Second ))
+ .Select( x => x.s * x.G));
+
+ return polynome.Sum();
+ }
+ }
+}

ADD
WalletWasabi/Crypto/ScalarVector.cs
+using System.Collections;
+using System.Collections.Generic;
+using System.Linq;
+using NBitcoin.Secp256k1;
+
+namespace WalletWasabi.Crypto
+{
+ public class ScalarVector : IEnumerable<Scalar>
+ {
+ public ScalarVector(IEnumerable<Scalar> scalars)
+ {
+ Scalars = scalars.ToArray();
+ }
+
+ private IEnumerable<Scalar> Scalars { get; }
+
+ public IEnumerator<Scalar> GetEnumerator() =>
+ Scalars.GetEnumerator();
+
+ public int Count => Scalars.Count();
+
+ IEnumerator IEnumerable.GetEnumerator() =>
+ GetEnumerator();
+ }
+}

ADD
WalletWasabi/Crypto/Term.cs
+using NBitcoin.Secp256k1;
+using WalletWasabi.Crypto.Groups;
+
+namespace WalletWasabi.Crypto
+{
+ public class Term
+ { public Term(Scalar scalar, GroupElement groupElement)
+ {
+ Scalar = scalar;
+ GroupElement = groupElement;
+ }
+
+ public Scalar Scalar { get; }
+ public GroupElement GroupElement { get; }
+ public GroupElement Eval() => Scalar * GroupElement;
+ }
+}

GE and Scalar vectors