internal static bool Pubkey_parse(ReadOnlySpan <byte> pub, out bool compressed, out GE elem) { compressed = false; elem = default; if (pub.Length == 33 && (pub[0] == SECP256K1_TAG_PUBKEY_EVEN || pub[0] == SECP256K1_TAG_PUBKEY_ODD)) { compressed = true; return (FE.TryCreate(pub.Slice(1), out var x) && GE.TryCreateXOVariable(x, pub[0] == SECP256K1_TAG_PUBKEY_ODD, out elem)); } else if (pub.Length == 65 && (pub[0] == SECP256K1_TAG_PUBKEY_UNCOMPRESSED || pub[0] == SECP256K1_TAG_PUBKEY_HYBRID_EVEN || pub[0] == SECP256K1_TAG_PUBKEY_HYBRID_ODD)) { if (!FE.TryCreate(pub.Slice(1), out var x) || !FE.TryCreate(pub.Slice(33), out var y)) { return(false); } elem = new GE(x, y); if ((pub[0] == SECP256K1_TAG_PUBKEY_HYBRID_EVEN || pub[0] == SECP256K1_TAG_PUBKEY_HYBRID_ODD) && y.IsOdd != (pub[0] == SECP256K1_TAG_PUBKEY_HYBRID_ODD)) { return(false); } return(elem.IsValidVariable); } else { return(false); } }
public void ConstructorThrows() { var one = new FE(1); var two = new FE(2); var large = new FE(uint.MaxValue); var largest = new FE(uint.MaxValue, uint.MaxValue, uint.MaxValue, uint.MaxValue, uint.MaxValue, uint.MaxValue, uint.MaxValue, uint.MaxValue, uint.MaxValue, uint.MaxValue); Assert.Throws <ArgumentOutOfRangeException>(() => new GroupElement(new GE(FE.Zero, FE.Zero))); Assert.Throws <ArgumentOutOfRangeException>(() => new GroupElement(new GE(one, FE.Zero))); Assert.Throws <ArgumentOutOfRangeException>(() => new GroupElement(new GE(one, one))); Assert.Throws <ArgumentOutOfRangeException>(() => new GroupElement(new GE(one, two))); Assert.Throws <ArgumentOutOfRangeException>(() => new GroupElement(new GE(two, two))); Assert.Throws <ArgumentOutOfRangeException>(() => new GroupElement(new GE(one, large))); Assert.Throws <ArgumentOutOfRangeException>(() => new GroupElement(new GE(large, large))); Assert.Throws <ArgumentOutOfRangeException>(() => new GroupElement(new GE(one, largest))); Assert.Throws <ArgumentOutOfRangeException>(() => new GroupElement(new GE(largest, largest))); Assert.Throws <ArgumentOutOfRangeException>(() => new GroupElement(new GEJ(FE.Zero, FE.Zero, FE.Zero))); Assert.Throws <ArgumentOutOfRangeException>(() => new GroupElement(new GEJ(one, FE.Zero, FE.Zero))); Assert.Throws <ArgumentOutOfRangeException>(() => new GroupElement(new GEJ(one, one, one))); Assert.Throws <ArgumentOutOfRangeException>(() => new GroupElement(new GEJ(one, one, two))); Assert.Throws <ArgumentOutOfRangeException>(() => new GroupElement(new GEJ(two, two, two))); Assert.Throws <ArgumentOutOfRangeException>(() => new GroupElement(new GEJ(one, one, large))); Assert.Throws <ArgumentOutOfRangeException>(() => new GroupElement(new GEJ(large, large, large))); Assert.Throws <ArgumentOutOfRangeException>(() => new GroupElement(new GEJ(one, one, largest))); Assert.Throws <ArgumentOutOfRangeException>(() => new GroupElement(new GEJ(largest, largest, largest))); }
public static GE CONST(uint a, uint b, uint c, uint d, uint e, uint f, uint g, uint h, uint i, uint j, uint k, uint l, uint m, uint n, uint o, uint p) { return(new GE( FE.CONST(a, b, c, d, e, f, g, h), FE.CONST(i, j, k, l, m, n, o, p), false )); }
public static void SeedHostDb(FE - practiceDbContext context) { context.SuppressAutoSetTenantId = true; // Host seed new InitialHostDbBuilder(context).Create(); // Default tenant seed (in host database). new DefaultTenantBuilder(context).Create(); new TenantRoleAndUserBuilder(context, 1).Create(); }
public ErrorInfo(DBFE error) { KE = error.KE; FE = error.FE; var parts = FE.Split(new[] { ' ' }, 2); Code = parts.Length < 1 ? string.Empty : parts[0]; Message = parts.Length < 2 ? string.Empty : parts[1].TrimEnd(); }
protected override void OnModelCreating(DbModelBuilder modelBuilder) { modelBuilder.Entity <TiposTelefonos>() .HasMany <Clientes>(c => c.Client) .WithMany(d => d.Tipo) .Map(FE => { FE.MapLeftKey("TipoId"); FE.MapRightKey("ClienteId"); FE.ToTable("ClientesTelefonos"); }); }
public static void SetAllGroupElementJacobianVariable(Span <GE> r, ReadOnlySpan <GEJ> a, int len) { FE u; int i; int last_i = SIZE_MAX; for (i = 0; i < len; i++) { if (!a[i].infinity) { /* Use destination's x coordinates as scratch space */ if (last_i == SIZE_MAX) { r[i] = new GE(a[i].z, r[i].y, r[i].infinity); } else { FE rx = r[last_i].x * a[i].z; r[i] = new GE(rx, r[i].y, r[i].infinity); } last_i = i; } } if (last_i == SIZE_MAX) { return; } u = r[last_i].x.InverseVariable(); i = last_i; while (i > 0) { i--; if (!a[i].infinity) { FE rx = r[i].x * u; r[last_i] = new GE(rx, r[last_i].y, r[last_i].infinity); u = u * a[last_i].z; last_i = i; } } VERIFY_CHECK(!a[last_i].infinity); r[last_i] = new GE(u, r[last_i].y, r[last_i].infinity); for (i = 0; i < len; i++) { r[i] = new GE(r[i].x, r[i].y, a[i].infinity); if (!a[i].infinity) { r[i] = a[i].ToGroupElementZInv(r[i].x); } } }
// Token: 0x060001CD RID: 461 RVA: 0x00018010 File Offset: 0x00016210 public void ActC3() { Entity FacingE = base.FacingEntity(500f); bool flag = !Information.IsNothing(FacingE); if (flag) { foreach (Entity FE in this.Friendlies) { FE.LockTarget(FacingE, AITargetMode.FollowAndKill, 600); } } }
public static bool TryCreate(ReadOnlySpan <byte> input32, Context?context, [MaybeNullWhen(false)] out ECXOnlyPubKey pubkey) { pubkey = null; if (input32.Length != 32) { return(false); } if (!FE.TryCreate(input32, out var x)) { return(false); } return(TryCreate(x, context, out pubkey)); }
public static void IdTest() { var id1 = FE.Id <int>(); var id2 = FE.Id <char>(); var id3 = FE.Id <List <int> >(); Assert.Equal(5, id1.Compile()(5)); Assert.Equal('c', id2.Compile()('c')); Assert.Equal(new List <int> { 1, 2, 3 }, id3.Compile()(new List <int> { 1, 2, 3 })); }
private FE random_fe() { FE field; Span <byte> output = stackalloc byte[32]; do { secp256k1_rand256(output); if (FE.TryCreate(output, out field)) { return(field); } } while (true); }
public static bool TryCreateXOVariable(FE x, bool odd, out GE result) { if (!TryCreateXQuad(x, out result)) { return(false); } var ry = result.y.NormalizeVariable(); if (ry.IsOdd != odd) { ry = ry.Negate(1); } result = new GE(result.x, ry, result.infinity); return(true); }
public static bool TryCreate(ReadOnlySpan <byte> in32, out SchnorrNonce?schnorrNonce) { schnorrNonce = null; if (in32.Length != 32) { return(false); } schnorrNonce = null; if (!FE.TryCreate(in32, out var fe)) { return(false); } schnorrNonce = new SchnorrNonce(fe); return(true); }
private static GroupElement GroupElementFromText(string text) { FE x; GE ge; int nonce = 0; using var sha256 = SHA256Managed.Create(); do { x = new FE(sha256.ComputeHash(Encoding.UTF8.GetBytes(text + nonce))); nonce++; }while (!GE.TryCreateXOVariable(x, true, out ge)); return(new GroupElement(ge)); }
FE random_field_element_test() { FE field; Span <byte> output = stackalloc byte[32]; do { RandomUtils.GetBytes(output); if (FE.TryCreate(output, out field)) { break; } } while (true); return(field); }
public static bool TryCreate(ReadOnlySpan <byte> in64, out SecpSchnorrSignature?signature) { signature = null; if (in64.Length != 64) { return(false); } if (FE.TryCreate(in64.Slice(0, 32), out var fe) && new Scalar(in64.Slice(32, 32), out int overflow) is Scalar scalar && overflow == 0) { signature = new SecpSchnorrSignature(fe, scalar); return(true); } return(false); }
// Token: 0x060001CB RID: 459 RVA: 0x00017E50 File Offset: 0x00016050 public void ActC1() { foreach (Entity e in Ground.CStack.eList) { bool flag = !e.IsDead; if (flag) { bool flag2 = !(e == this) && e.ChekRelation(this) != EntityRelationMode.Friends; if (flag2) { foreach (Entity FE in this.Friendlies) { FE.LockTarget(e, AITargetMode.FollowAndKill, 600); } } } } }
public void ValidatingOnSameZCoord(int[] ObjNumbers) { var toRemove = new List <int>(); var slabsNodes = new List <FE>(); var s = new FE { }; foreach (var slabNumber in ObjNumbers) { s = new FE(); var slab = (RobotObjObject)str.Objects.Get(slabNumber); s.Panel_ID = slabNumber; s.nodes = new List <Node>(); var modelPoints = (RobotGeoPoint3DCollection)slab.Main.ModelPoints; for (int i = 1; i <= modelPoints.Count; i++) { var r = (RobotGeoPoint3D)modelPoints.Get(i); s.nodes.Add(new Node { X = r.X, Y = r.Y, A = r.Z }); } slabsNodes.Add(s); } double Z = 0; slabsNodes.ForEach(x => { if (slabsNodes.IndexOf(x) == 0) { Z = x.nodes.FirstOrDefault().A; } if (x.nodes.Any(y => y.A != Z)) { toRemove.Add(x.Panel_ID); } }); if (toRemove.Count != 0) { throw new Exception($"Slabs {toRemove.ToArray().ToRobotSelectionString()} not on same Z coordinat as {slabsNodes[0].Panel_ID}"); } }
public static bool TryCreateXQuad(FE x, out GE result) { result = GE.Zero; FE rx, ry; bool rinfinity; FE x2, x3, c; rx = x; x2 = x.Sqr(); x3 = x * x2; rinfinity = false; c = new FE(EC.CURVE_B); c += x3; if (!c.Sqrt(out ry)) { return(false); } result = new GE(rx, ry, rinfinity); return(true); }
public static IList <string> GetFiles(string[] exclusions) { IEnumerable <string> directory; IList <string> normalizedExclusions = new List <string>(); exclusions.ToList().ForEach(FE => normalizedExclusions.Add(FE.ToLower())); try { directory = Directory.EnumerateFiles("Pages", "*", SearchOption.AllDirectories); } catch (Exception e) { // haxors to get the pages directory from the publish folder... gotta be a better way Console.WriteLine(e); directory = Directory.EnumerateFiles("../../../../Pages", "*", SearchOption.AllDirectories); } return(directory.Where(W => normalizedExclusions.Where(W2 => W.ToLower().Contains(W2)).Count() == 0).ToList()); }
public MusigContext(MusigContext musigContext) { if (musigContext == null) { throw new ArgumentNullException(nameof(musigContext)); } musigContext.pk_hash.CopyTo(pk_hash.AsSpan()); second_pk_x = musigContext.second_pk_x; pk_parity = musigContext.pk_parity; is_tweaked = musigContext.is_tweaked; scalar_tweak = musigContext.scalar_tweak; internal_key_parity = musigContext.internal_key_parity; processed_nonce = musigContext.processed_nonce; SessionCache = musigContext.SessionCache?.Clone(); pubKeys = musigContext.pubKeys.ToArray(); aggregateNonce = musigContext.aggregateNonce; aggregatePubKey = musigContext.aggregatePubKey; tweakedPubKey = musigContext.tweakedPubKey; ctx = musigContext.ctx; msg32 = musigContext.msg32; }
// super method that calls for drawing of missiles, planes, Flaks, explosions, and false explosions private void DrawGameElements() { int[] from, to; foreach (Missile M in missiles) { from = M.GetStartCoords(); to = M.GetMyCoords(); DrawMissile(from[0], from[1], to[0], to[1], 0); DrawTail(M.GetTail()); } foreach (Plane P in planes) { to = P.GetMyCoords(); DrawPlane(to[0], to[1], P.GetPlaneType(), P.GetDirection()); } foreach (Flak F in flaks) { from = F.GetStartCoords(); to = F.GetMyCoords(); DrawMissile(from[0], from[1], to[0], to[1], 1); } foreach (Explosion E in explosions) { to = E.getCoords(); DrawExplosion(to[0], to[1], E.getSize()); } foreach (FalseExplosion FE in falseExplosions) { to = FE.getCoords(); DrawExplosion(to[0], to[1], FE.getSize()); } }
public void NonNormalizedPointDeserialization() { var p = FE.CONST( 0xFFFFFC2FU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU); var x = EC.G.x; x = x.Add(p); var x3 = x * x * x; var y2 = x3 + new FE(EC.CURVE_B); Assert.True(y2.Sqrt(out var y)); var ge = new GroupElement(new GE(x, y)); var ge2 = GroupElement.FromBytes(ge.ToBytes()); Assert.Equal(ge, ge2); }
public DefaultTenantBuilder(FE - practiceDbContext context) { _context = context; }
public ECMultGenContext() { Span <GE> prec = stackalloc GE[1024]; GEJ gj; GEJ nums_gej; int i, j; this.prec = new GEStorage[64, 16]; gj = EC.G.ToGroupElementJacobian(); /* Construct a group element with no known corresponding scalar (nothing up my sleeve). */ { var nums_b32 = "The scalar for this x is unknown".ToCharArray().Select(b => (byte)b).ToArray(); FE nums_x; GE nums_ge; var r = FE.TryCreate(nums_b32, out nums_x); VERIFY_CHECK(r); r = GE.TryCreateXOVariable(nums_x, false, out nums_ge); VERIFY_CHECK(r); nums_gej = nums_ge.ToGroupElementJacobian(); /* Add G to make the bits in x uniformly distributed. */ nums_gej = nums_gej.AddVariable(EC.G, out _); } /* compute prec. */ { Span <GEJ> precj = stackalloc GEJ[1024]; /* Jacobian versions of prec. */ GEJ gbase; GEJ numsbase; gbase = gj; /* 16^j * G */ numsbase = nums_gej; /* 2^j * nums. */ for (j = 0; j < 64; j++) { /* Set precj[j*16 .. j*16+15] to (numsbase, numsbase + gbase, ..., numsbase + 15*gbase). */ precj[j * 16] = numsbase; for (i = 1; i < 16; i++) { precj[j * 16 + i] = precj[j * 16 + i - 1].AddVariable(gbase, out _); } /* Multiply gbase by 16. */ for (i = 0; i < 4; i++) { gbase = gbase.DoubleVariable(); } /* Multiply numbase by 2. */ numsbase = numsbase.DoubleVariable(); if (j == 62) { /* In the last iteration, numsbase is (1 - 2^j) * nums instead. */ numsbase = numsbase.Negate(); numsbase = numsbase.AddVariable(nums_gej, out _); } } GE.SetAllGroupElementJacobianVariable(prec, precj, 1024); } for (j = 0; j < 64; j++) { for (i = 0; i < 16; i++) { this.prec[j, i] = prec[j * 16 + i].ToStorage(); } } Blind(); }
internal SecpSchnorrSignature(FE rx, Scalar s) { this.rx = rx; this.s = s; }
public DataTable SaberFechaVencimiento(int prestamo) { return(FE.GetDataUltimaFecha(prestamo)); }
public void cargar_cobranzas(string ncontrato) { dtgCCanceladas.DataSource = null; dtgCPendientes.DataSource = null; txtTotCanCobranzas.Text = ""; txtGLCobranzas.Text = ""; txtICCobranzas.Text = ""; txtGICobranzas.Text = ""; txtFECobranzas.Text = ""; txtTGCobranzas.Text = ""; txtObsCobranzas.Text = ""; double TC, GL, IC, GI, FE, TG; TC = GL = IC = GI = FE = TG = 0; lblNContratoCobranzas.Text = "Contrato N° " + ncontrato; string txtSQL = "Select TipoCuota,NroCuota,TotalCuotas,MontoCuota,FechaCuota from Giros where NroContrato='" + ncontrato + "' and Estatus='PENDIENTE' Order by FechaCuota,TotalCuotas"; if (Globales.BD.nregistros(txtSQL) > 0) { Globales.BD.dtt = Globales.BD.generar_datatable(txtSQL, CommandType.Text, new List <Clases.Parameters>()); dtgCPendientes.DataSource = Globales.BD.dtt; //dtgCPendientes.Columns[4].Visible = false; foreach (DataRow row in Globales.BD.dtt.Rows) { if (row["TipoCuota"] != DBNull.Value) { if (Convert.ToString(row["TipoCuota"]) == "GIRO") { GI += Convert.ToDouble(row["MontoCuota"]); } else if (Convert.ToString(row["TipoCuota"]) == "COMPLEMENTARIA") { IC += Convert.ToDouble(row["MontoCuota"]); } else if (Convert.ToString(row["TipoCuota"]) == "GASTOSLEGALES") { GL += Convert.ToDouble(row["MontoCuota"]); } else if (Convert.ToString(row["TipoCuota"]).Length > 21) { if (Convert.ToString(row["TipoCuota"]).Substring(0, 21) == "FINANCIAMIENTOESPECIAL") { FE += Convert.ToDouble(row["MontoCuota"]); } } } TG += Convert.ToDouble(row["MontoCuota"]); } txtGLCobranzas.Text = GL.ToString("N2") + " Bs."; txtICCobranzas.Text = IC.ToString("N2") + " Bs."; txtGICobranzas.Text = GI.ToString("N2") + " Bs."; txtFECobranzas.Text = FE.ToString("N2") + " Bs."; txtTGCobranzas.Text = TG.ToString("N2") + " Bs."; } txtSQL = "Select TipoCuota,NroCuota,TotalCuotas,MontoCuota,FechaCancelado from Giros where NroContrato='" + ncontrato + "' and Estatus='CANCELADO' Order by FechaCuota,TotalCuotas"; if (Globales.BD.nregistros(txtSQL) > 0) { Globales.BD.dtt = Globales.BD.generar_datatable(txtSQL, CommandType.Text, new List <Clases.Parameters>()); dtgCCanceladas.DataSource = Globales.BD.dtt; //dtgCCanceladas.Columns[4].Visible = false; foreach (DataRow row in Globales.BD.dtt.Rows) { TC += Convert.ToDouble(row["MontoCuota"]); } txtTotCanCobranzas.Text = TC.ToString("N2") + " Bs."; } }
public HostRoleAndUserCreator(FE - practiceDbContext context) { _context = context; }
public void Blind(byte[]?seed32 = null) { Scalar b; GEJ gb; FE s; Span <byte> nonce32 = stackalloc byte[32]; using RFC6979HMACSHA256 rng = new RFC6979HMACSHA256(); bool retry; Span <byte> keydata = stackalloc byte[64]; if (seed32 == null) { /* When seed is NULL, reset the initial point and blinding value. */ initial = EC.G.ToGroupElementJacobian(); initial = initial.Negate(); blind = new Scalar(1); } /* The prior blinding value (if not reset) is chained forward by including it in the hash. */ blind.WriteToSpan(nonce32); /* Using a CSPRNG allows a failure free interface, avoids needing large amounts of random data, * and guards against weak or adversarial seeds. This is a simpler and safer interface than * asking the caller for blinding values directly and expecting them to retry on failure. */ nonce32.CopyTo(keydata); if (seed32 != null) { seed32.AsSpan().CopyTo(keydata.Slice(32, 32)); } else { keydata = keydata.Slice(0, 32); } rng.Initialize(keydata); keydata.Clear(); /* Retry for out of range results to achieve uniformity. */ do { rng.Generate(nonce32); retry = !FE.TryCreate(nonce32, out s); retry |= s.IsZero; } while (retry); /* This branch true is cryptographically unreachable. Requires sha256_hmac output > Fp. */ /* Randomize the projection to defend against multiplier sidechannels. */ initial = initial.Rescale(s); FE.Clear(ref s); do { rng.Generate(nonce32); b = new Scalar(nonce32, out int overflow); retry = overflow == 1; /* A blinding value of 0 works, but would undermine the projection hardening. */ retry |= b.IsZero; } while (retry); /* This branch true is cryptographically unreachable. Requires sha256_hmac output > order. */ rng.Dispose(); nonce32.Fill(0); gb = MultGen(b); b = b.Negate(); blind = b; initial = gb; Scalar.Clear(ref b); GEJ.Clear(ref gb); }