mirror of
https://github.com/burrow-dev/burrow-server.git
synced 2026-11-21 01:37:50 -05:00
Brought up to date with the private repository (feea4c7)
This commit is contained in:
1 parent
1aa738d692
commit
1b1df1ae48
7925 files changed
+2617237
-20
No files matched your search
@@ -0,0 +1,83 @@
|
||||
package com.hurlant.math
|
||||
{
|
||||
use namespace bi_internal;
|
||||
|
||||
internal class BarrettReduction implements IReduction
|
||||
{
|
||||
|
||||
private var m:BigInteger;
|
||||
|
||||
private var r2:BigInteger;
|
||||
|
||||
private var q3:BigInteger;
|
||||
|
||||
private var mu:BigInteger;
|
||||
|
||||
public function BarrettReduction(param1:BigInteger)
|
||||
{
|
||||
super();
|
||||
this.r2 = new BigInteger();
|
||||
this.q3 = new BigInteger();
|
||||
BigInteger.ONE.dlShiftTo(2 * param1.t,this.r2);
|
||||
this.mu = this.r2.divide(param1);
|
||||
this.m = param1;
|
||||
}
|
||||
|
||||
public function revert(param1:BigInteger) : BigInteger
|
||||
{
|
||||
return param1;
|
||||
}
|
||||
|
||||
public function mulTo(param1:BigInteger, param2:BigInteger, param3:BigInteger) : void
|
||||
{
|
||||
param1.multiplyTo(param2,param3);
|
||||
this.reduce(param3);
|
||||
}
|
||||
|
||||
public function sqrTo(param1:BigInteger, param2:BigInteger) : void
|
||||
{
|
||||
param1.squareTo(param2);
|
||||
this.reduce(param2);
|
||||
}
|
||||
|
||||
public function convert(param1:BigInteger) : BigInteger
|
||||
{
|
||||
var _loc2_:BigInteger = null;
|
||||
if(param1.s < 0 || param1.t > 2 * this.m.t)
|
||||
{
|
||||
return param1.mod(this.m);
|
||||
}
|
||||
if(param1.compareTo(this.m) < 0)
|
||||
{
|
||||
return param1;
|
||||
}
|
||||
_loc2_ = new BigInteger();
|
||||
param1.copyTo(_loc2_);
|
||||
this.reduce(_loc2_);
|
||||
return _loc2_;
|
||||
}
|
||||
|
||||
public function reduce(param1:BigInteger) : void
|
||||
{
|
||||
var _loc2_:BigInteger = param1 as BigInteger;
|
||||
_loc2_.drShiftTo(this.m.t - 1,this.r2);
|
||||
if(_loc2_.t > this.m.t + 1)
|
||||
{
|
||||
_loc2_.t = this.m.t + 1;
|
||||
_loc2_.clamp();
|
||||
}
|
||||
this.mu.multiplyUpperTo(this.r2,this.m.t + 1,this.q3);
|
||||
this.m.multiplyLowerTo(this.q3,this.m.t + 1,this.r2);
|
||||
while(_loc2_.compareTo(this.r2) < 0)
|
||||
{
|
||||
_loc2_.dAddOffset(1,this.m.t + 1);
|
||||
}
|
||||
_loc2_.subTo(this.r2,_loc2_);
|
||||
while(_loc2_.compareTo(this.m) >= 0)
|
||||
{
|
||||
_loc2_.subTo(this.m,_loc2_);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,48 @@
|
||||
package com.hurlant.math
|
||||
{
|
||||
use namespace bi_internal;
|
||||
|
||||
internal class ClassicReduction implements IReduction
|
||||
{
|
||||
|
||||
private var m:BigInteger;
|
||||
|
||||
public function ClassicReduction(param1:BigInteger)
|
||||
{
|
||||
super();
|
||||
this.m = param1;
|
||||
}
|
||||
|
||||
public function convert(param1:BigInteger) : BigInteger
|
||||
{
|
||||
if(param1.s < 0 || param1.compareTo(this.m) >= 0)
|
||||
{
|
||||
return param1.mod(this.m);
|
||||
}
|
||||
return param1;
|
||||
}
|
||||
|
||||
public function revert(param1:BigInteger) : BigInteger
|
||||
{
|
||||
return param1;
|
||||
}
|
||||
|
||||
public function reduce(param1:BigInteger) : void
|
||||
{
|
||||
param1.divRemTo(this.m,null,param1);
|
||||
}
|
||||
|
||||
public function mulTo(param1:BigInteger, param2:BigInteger, param3:BigInteger) : void
|
||||
{
|
||||
param1.multiplyTo(param2,param3);
|
||||
this.reduce(param3);
|
||||
}
|
||||
|
||||
public function sqrTo(param1:BigInteger, param2:BigInteger) : void
|
||||
{
|
||||
param1.squareTo(param2);
|
||||
this.reduce(param2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.hurlant.math
|
||||
{
|
||||
internal interface IReduction
|
||||
{
|
||||
|
||||
function convert(param1:BigInteger) : BigInteger;
|
||||
|
||||
function revert(param1:BigInteger) : BigInteger;
|
||||
|
||||
function reduce(param1:BigInteger) : void;
|
||||
|
||||
function mulTo(param1:BigInteger, param2:BigInteger, param3:BigInteger) : void;
|
||||
|
||||
function sqrTo(param1:BigInteger, param2:BigInteger) : void;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,95 @@
|
||||
package com.hurlant.math
|
||||
{
|
||||
use namespace bi_internal;
|
||||
|
||||
internal class MontgomeryReduction implements IReduction
|
||||
{
|
||||
|
||||
private var m:BigInteger;
|
||||
|
||||
private var mp:int;
|
||||
|
||||
private var mpl:int;
|
||||
|
||||
private var mph:int;
|
||||
|
||||
private var um:int;
|
||||
|
||||
private var mt2:int;
|
||||
|
||||
public function MontgomeryReduction(param1:BigInteger)
|
||||
{
|
||||
super();
|
||||
this.m = param1;
|
||||
this.mp = param1.invDigit();
|
||||
this.mpl = this.mp & 0x7FFF;
|
||||
this.mph = this.mp >> 15;
|
||||
this.um = (1 << BigInteger.DB - 15) - 1;
|
||||
this.mt2 = 2 * param1.t;
|
||||
}
|
||||
|
||||
public function convert(param1:BigInteger) : BigInteger
|
||||
{
|
||||
var _loc2_:BigInteger = new BigInteger();
|
||||
param1.abs().dlShiftTo(this.m.t,_loc2_);
|
||||
_loc2_.divRemTo(this.m,null,_loc2_);
|
||||
if(param1.s < 0 && _loc2_.compareTo(BigInteger.ZERO) > 0)
|
||||
{
|
||||
this.m.subTo(_loc2_,_loc2_);
|
||||
}
|
||||
return _loc2_;
|
||||
}
|
||||
|
||||
public function revert(param1:BigInteger) : BigInteger
|
||||
{
|
||||
var _loc2_:BigInteger = new BigInteger();
|
||||
param1.copyTo(_loc2_);
|
||||
this.reduce(_loc2_);
|
||||
return _loc2_;
|
||||
}
|
||||
|
||||
public function reduce(param1:BigInteger) : void
|
||||
{
|
||||
var _loc3_:int = 0;
|
||||
var _loc4_:int = 0;
|
||||
while(param1.t <= this.mt2)
|
||||
{
|
||||
var _loc5_:Number;
|
||||
param1.a[_loc5_ = param1.t++] = 0;
|
||||
}
|
||||
var _loc2_:int = 0;
|
||||
while(_loc2_ < this.m.t)
|
||||
{
|
||||
_loc3_ = param1.a[_loc2_] & 0x7FFF;
|
||||
_loc4_ = _loc3_ * this.mpl + ((_loc3_ * this.mph + (param1.a[_loc2_] >> 15) * this.mpl & this.um) << 15) & BigInteger.DM;
|
||||
_loc3_ = _loc2_ + this.m.t;
|
||||
param1.a[_loc3_] += this.m.am(0,_loc4_,param1,_loc2_,0,this.m.t);
|
||||
while(param1.a[_loc3_] >= BigInteger.DV)
|
||||
{
|
||||
param1.a[_loc3_] -= BigInteger.DV;
|
||||
++param1.a[++_loc3_];
|
||||
}
|
||||
_loc2_++;
|
||||
}
|
||||
param1.clamp();
|
||||
param1.drShiftTo(this.m.t,param1);
|
||||
if(param1.compareTo(this.m) >= 0)
|
||||
{
|
||||
param1.subTo(this.m,param1);
|
||||
}
|
||||
}
|
||||
|
||||
public function sqrTo(param1:BigInteger, param2:BigInteger) : void
|
||||
{
|
||||
param1.squareTo(param2);
|
||||
this.reduce(param2);
|
||||
}
|
||||
|
||||
public function mulTo(param1:BigInteger, param2:BigInteger, param3:BigInteger) : void
|
||||
{
|
||||
param1.multiplyTo(param2,param3);
|
||||
this.reduce(param3);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
package com.hurlant.math
|
||||
{
|
||||
use namespace bi_internal;
|
||||
|
||||
public class NullReduction implements IReduction
|
||||
{
|
||||
|
||||
public function NullReduction()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public function revert(param1:BigInteger) : BigInteger
|
||||
{
|
||||
return param1;
|
||||
}
|
||||
|
||||
public function mulTo(param1:BigInteger, param2:BigInteger, param3:BigInteger) : void
|
||||
{
|
||||
param1.multiplyTo(param2,param3);
|
||||
}
|
||||
|
||||
public function sqrTo(param1:BigInteger, param2:BigInteger) : void
|
||||
{
|
||||
param1.squareTo(param2);
|
||||
}
|
||||
|
||||
public function convert(param1:BigInteger) : BigInteger
|
||||
{
|
||||
return param1;
|
||||
}
|
||||
|
||||
public function reduce(param1:BigInteger) : void
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
package com.hurlant.math
|
||||
{
|
||||
public namespace bi_internal = "http://crypto.hurlant.com/BigInteger";
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user