aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/bigint.h4
-rw-r--r--src/big_base.cpp17
2 files changed, 19 insertions, 2 deletions
diff --git a/include/bigint.h b/include/bigint.h
index 44382b063..1772f1e51 100644
--- a/include/bigint.h
+++ b/include/bigint.h
@@ -78,8 +78,8 @@ class BigInt
SecureVector<word>& get_reg() { return reg; }
void grow_reg(u32bit) const;
- word& operator[](u32bit index) { return reg[index]; }
- word operator[](u32bit index) const { return reg[index]; }
+ word& operator[](u32bit);
+ word operator[](u32bit) const;
void clear() { reg.clear(); }
void randomize(u32bit = 0);
diff --git a/src/big_base.cpp b/src/big_base.cpp
index 158d967fb..a6d9e3e9e 100644
--- a/src/big_base.cpp
+++ b/src/big_base.cpp
@@ -338,6 +338,23 @@ BigInt BigInt::operator-() const
}
/*************************************************
+* Return a reference to the indexed word *
+*************************************************/
+word& BigInt::operator[](u32bit index)
+ {
+ reg.grow_to(index+1);
+ return reg[index];
+ }
+
+/*************************************************
+* Return the value of the indexed word *
+*************************************************/
+word BigInt::operator[](u32bit index) const
+ {
+ return (index < size()) ? reg[index] : 0;
+ }
+
+/*************************************************
* Return the absolute value of this number *
*************************************************/
BigInt BigInt::abs() const