Skip to content

Commit 9bfa512

Browse files
DRIVERS-2767 QE Range Protocol v2 (#1587)
--------- Co-authored-by: Kevin Albertson <[email protected]>
1 parent 88b994e commit 9bfa512

File tree

137 files changed

+882
-1769
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

137 files changed

+882
-1769
lines changed

source/client-side-encryption/client-side-encryption.md

Lines changed: 16 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -982,8 +982,7 @@ class ClientEncryption {
982982
// 2. An Aggregate Expression of this form:
983983
// {$and: [{$gt: [<fieldpath>, <value1>]}, {$lt: [<fieldpath>, <value2>]}]
984984
// $gt may also be $gte. $lt may also be $lte.
985-
// Only supported when queryType is "rangePreview" and algorithm is "RangePreview".
986-
// NOTE: The Range algorithm is experimental only. It is not intended for public use. It is subject to breaking changes.
985+
// Only supported when queryType is "range" and algorithm is "Range".
987986
encryptExpression(expr: Document, opts: EncryptOpts): Document;
988987

989988
// Decrypts an encrypted value (BSON binary of subtype 6).
@@ -1168,15 +1167,15 @@ class EncryptOpts {
11681167
rangeOpts: Optional<RangeOpts>
11691168
}
11701169

1171-
// NOTE: The Range algorithm is experimental only. It is not intended for public use. It is subject to breaking changes.
1172-
// RangeOpts specifies index options for a Queryable Encryption field supporting "rangePreview" queries.
1173-
// min, max, sparsity, and precision must match the values set in the encryptedFields of the destination collection.
1170+
// RangeOpts specifies index options for a Queryable Encryption field supporting "range" queries.
1171+
// min, max, trimFactor, sparsity, and precision must match the values set in the encryptedFields of the destination collection.
11741172
// For double and decimal128, min/max/precision must all be set, or all be unset.
11751173
class RangeOpts {
11761174
// min is required if precision is set.
11771175
min: Optional<BSONValue>,
11781176
// max is required if precision is set.
11791177
max: Optional<BSONValue>,
1178+
trimFactor: Int32,
11801179
sparsity: Int64,
11811180
// precision may only be set for double or decimal128.
11821181
precision: Optional<Int32>
@@ -1202,46 +1201,33 @@ One of the strings:
12021201
- "AEAD_AES_256_CBC_HMAC_SHA_512-Random"
12031202
- "Indexed"
12041203
- "Unindexed"
1205-
- "RangePreview"
1204+
- "Range"
12061205

1207-
The result of explicit encryption with the "Indexed" or "RangePreview" algorithm must be processed by the server to
1208-
insert or query. Drivers MUST document the following behavior:
1206+
The result of explicit encryption with the "Indexed" or "Range" algorithm must be processed by the server to insert or
1207+
query. Drivers MUST document the following behavior:
12091208

1210-
> To insert or query with an "Indexed" or "RangePreview" encrypted payload, use a `MongoClient` configured with
1209+
> To insert or query with an "Indexed" or "Range" encrypted payload, use a `MongoClient` configured with
12111210
> `AutoEncryptionOpts`. `AutoEncryptionOpts.bypassQueryAnalysis` may be true. `AutoEncryptionOpts.bypassAutoEncryption`
12121211
> must be false.
12131212

1214-
> [!NOTE]
1215-
> The Range algorithm is experimental only. It is not intended for public use. It is subject to breaking changes.
1216-
12171213
#### contentionFactor
12181214

1219-
contentionFactor only applies when algorithm is "Indexed" or "RangePreview". It is an error to set contentionFactor when
1220-
algorithm is not "Indexed" or "RangePreview".
1221-
1222-
> [!NOTE]
1223-
> The Range algorithm is experimental only. It is not intended for public use. It is subject to breaking changes.
1215+
contentionFactor only applies when algorithm is "Indexed" or "Range". It is an error to set contentionFactor when
1216+
algorithm is not "Indexed" or "Range".
12241217

12251218
#### queryType
12261219

12271220
One of the strings:
12281221

12291222
- "equality"
1230-
- "rangePreview"
1223+
- "range"
12311224

1232-
queryType only applies when algorithm is "Indexed" or "RangePreview". It is an error to set queryType when algorithm is
1233-
not "Indexed" or "RangePreview".
1234-
1235-
> [!NOTE]
1236-
> The Range algorithm is experimental only. It is not intended for public use. It is subject to breaking changes.
1225+
queryType only applies when algorithm is "Indexed" or "Range". It is an error to set queryType when algorithm is not
1226+
"Indexed" or "Range".
12371227

12381228
#### rangeOpts
12391229

1240-
rangeOpts only applies when algorithm is "rangePreview". It is an error to set rangeOpts when algorithm is not
1241-
"rangePreview".
1242-
1243-
> [!NOTE]
1244-
> The Range algorithm is experimental only. It is not intended for public use. It is subject to breaking changes.
1230+
rangeOpts only applies when algorithm is "range". It is an error to set rangeOpts when algorithm is not "range".
12451231

12461232
## User facing API: When Auto Encryption Fails
12471233

@@ -2389,6 +2375,8 @@ explicit session parameter as described in the [Drivers Sessions Specification](
23892375

23902376
## Changelog
23912377

2378+
- 2024-05-31: Replace rangePreview with range.
2379+
23922380
- 2024-03-20: Add `delegated` option to "kmip" KMS provider
23932381

23942382
- 2024-02-27: Migrated from reStructuredText to Markdown.

source/client-side-encryption/etc/data/range-encryptedFields-Date.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,13 @@
1010
"path": "encryptedDate",
1111
"bsonType": "date",
1212
"queries": {
13-
"queryType": "rangePreview",
13+
"queryType": "range",
1414
"contention": {
1515
"$numberLong": "0"
1616
},
17+
"trimFactor": {
18+
"$numberInt": "1"
19+
},
1720
"sparsity": {
1821
"$numberLong": "1"
1922
},
@@ -30,4 +33,4 @@
3033
}
3134
}
3235
]
33-
}
36+
}

source/client-side-encryption/etc/data/range-encryptedFields-DecimalNoPrecision.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,17 @@
1010
"path": "encryptedDecimalNoPrecision",
1111
"bsonType": "decimal",
1212
"queries": {
13-
"queryType": "rangePreview",
13+
"queryType": "range",
1414
"contention": {
1515
"$numberLong": "0"
1616
},
17+
"trimFactor": {
18+
"$numberInt": "1"
19+
},
1720
"sparsity": {
1821
"$numberLong": "1"
1922
}
2023
}
2124
}
2225
]
23-
}
26+
}

source/client-side-encryption/etc/data/range-encryptedFields-DecimalPrecision.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,13 @@
1010
"path": "encryptedDecimalPrecision",
1111
"bsonType": "decimal",
1212
"queries": {
13-
"queryType": "rangePreview",
13+
"queryType": "range",
1414
"contention": {
1515
"$numberLong": "0"
1616
},
17+
"trimFactor": {
18+
"$numberInt": "1"
19+
},
1720
"sparsity": {
1821
"$numberLong": "1"
1922
},
@@ -29,4 +32,4 @@
2932
}
3033
}
3134
]
32-
}
35+
}

source/client-side-encryption/etc/data/range-encryptedFields-DoubleNoPrecision.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,17 @@
1010
"path": "encryptedDoubleNoPrecision",
1111
"bsonType": "double",
1212
"queries": {
13-
"queryType": "rangePreview",
13+
"queryType": "range",
1414
"contention": {
1515
"$numberLong": "0"
1616
},
17+
"trimFactor": {
18+
"$numberInt": "1"
19+
},
1720
"sparsity": {
1821
"$numberLong": "1"
1922
}
2023
}
2124
}
2225
]
23-
}
26+
}

source/client-side-encryption/etc/data/range-encryptedFields-DoublePrecision.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,13 @@
1010
"path": "encryptedDoublePrecision",
1111
"bsonType": "double",
1212
"queries": {
13-
"queryType": "rangePreview",
13+
"queryType": "range",
1414
"contention": {
1515
"$numberLong": "0"
1616
},
17+
"trimFactor": {
18+
"$numberInt": "1"
19+
},
1720
"sparsity": {
1821
"$numberLong": "1"
1922
},
@@ -29,4 +32,4 @@
2932
}
3033
}
3134
]
32-
}
35+
}

source/client-side-encryption/etc/data/range-encryptedFields-Int.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,13 @@
1010
"path": "encryptedInt",
1111
"bsonType": "int",
1212
"queries": {
13-
"queryType": "rangePreview",
13+
"queryType": "range",
1414
"contention": {
1515
"$numberLong": "0"
1616
},
17+
"trimFactor": {
18+
"$numberInt": "1"
19+
},
1720
"sparsity": {
1821
"$numberLong": "1"
1922
},
@@ -26,4 +29,4 @@
2629
}
2730
}
2831
]
29-
}
32+
}

source/client-side-encryption/etc/data/range-encryptedFields-Long.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,13 @@
1010
"path": "encryptedLong",
1111
"bsonType": "long",
1212
"queries": {
13-
"queryType": "rangePreview",
13+
"queryType": "range",
1414
"contention": {
1515
"$numberLong": "0"
1616
},
17+
"trimFactor": {
18+
"$numberInt": "1"
19+
},
1720
"sparsity": {
1821
"$numberLong": "1"
1922
},
@@ -26,4 +29,4 @@
2629
}
2730
}
2831
]
29-
}
32+
}

source/client-side-encryption/etc/test-templates/fle2v2-Range-Date-Aggregate.yml.template renamed to source/client-side-encryption/etc/test-templates/fle2v2-Rangev2-Date-Aggregate.yml.template

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11

22
# Requires libmongocrypt 1.8.0.
33
runOn:
4-
- minServerVersion: "7.0.0"
4+
- minServerVersion: "8.0.0"
55
# Skip QEv2 (also referred to as FLE2v2) tests on Serverless. Unskip once Serverless enables the QEv2 protocol.
66
# FLE 2 Encrypted collections are not supported on standalone.
77
topology: [ "replicaset", "sharded", "load-balanced" ]
8-
# Skip tests for "rangePreview" algorithm on Server 8.0+. Server 8.0 drops "rangePreview" and adds "range".
9-
maxServerVersion: "7.99.99"
108
database_name: &database_name "default"
119
collection_name: &collection_name "default"
1210
data: []
@@ -124,12 +122,6 @@ tests:
124122
"_id": 0,
125123
"encryptedDate": { $$type: "binData" },
126124
"__safeContent__": [
127-
{
128-
"$binary": {
129-
"base64": "5nRutVIyq7URVOVtbE4vM01APSIajAVnsShMwjBlzkM=",
130-
"subType": "00"
131-
}
132-
},
133125
{
134126
"$binary": {
135127
"base64": "RjBYT2h3ZAoHxhf8DU6/dFbDkEBZp0IxREcsRTu2MXs=",
@@ -185,12 +177,6 @@ tests:
185177
"_id": 1,
186178
"encryptedDate": { $$type: "binData" },
187179
"__safeContent__": [
188-
{
189-
"$binary": {
190-
"base64": "bE1vqWj3KNyM7cCYUv/cnYm8BPaUL3eMp5syTHq6NF4=",
191-
"subType": "00"
192-
}
193-
},
194180
{
195181
"$binary": {
196182
"base64": "25j9sQXZCihCmHKvTHgaBsAVZFcGPn7JjHdrCGlwyyw=",

source/client-side-encryption/etc/test-templates/fle2v2-Range-Date-Correctness.yml.template renamed to source/client-side-encryption/etc/test-templates/fle2v2-Rangev2-Date-Correctness.yml.template

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,10 @@
33

44
# Requires libmongocrypt 1.8.0.
55
runOn:
6-
- minServerVersion: "7.0.0"
6+
- minServerVersion: "8.0.0"
77
# Skip QEv2 (also referred to as FLE2v2) tests on Serverless. Unskip once Serverless enables the QEv2 protocol.
88
# FLE 2 Encrypted collections are not supported on standalone.
99
topology: [ "replicaset", "sharded", "load-balanced" ]
10-
# Skip tests for "rangePreview" algorithm on Server 8.0+. Server 8.0 drops "rangePreview" and adds "range".
11-
maxServerVersion: "7.99.99"
1210
database_name: &database_name "default"
1311
collection_name: &collection_name "default"
1412
data: []

source/client-side-encryption/etc/test-templates/fle2v2-Range-Date-Delete.yml.template renamed to source/client-side-encryption/etc/test-templates/fle2v2-Rangev2-Date-Delete.yml.template

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11

22
# Requires libmongocrypt 1.8.0.
33
runOn:
4-
- minServerVersion: "7.0.0"
4+
- minServerVersion: "8.0.0"
55
# Skip QEv2 (also referred to as FLE2v2) tests on Serverless. Unskip once Serverless enables the QEv2 protocol.
66
# FLE 2 Encrypted collections are not supported on standalone.
77
topology: [ "replicaset", "sharded", "load-balanced" ]
8-
# Skip tests for "rangePreview" algorithm on Server 8.0+. Server 8.0 drops "rangePreview" and adds "range".
9-
maxServerVersion: "7.99.99"
108
database_name: &database_name "default"
119
collection_name: &collection_name "default"
1210
data: []
@@ -126,12 +124,6 @@ tests:
126124
"_id": 0,
127125
"encryptedDate": { $$type: "binData" },
128126
"__safeContent__": [
129-
{
130-
"$binary": {
131-
"base64": "5nRutVIyq7URVOVtbE4vM01APSIajAVnsShMwjBlzkM=",
132-
"subType": "00"
133-
}
134-
},
135127
{
136128
"$binary": {
137129
"base64": "RjBYT2h3ZAoHxhf8DU6/dFbDkEBZp0IxREcsRTu2MXs=",

source/client-side-encryption/etc/test-templates/fle2v2-Range-Date-FindOneAndUpdate.yml.template renamed to source/client-side-encryption/etc/test-templates/fle2v2-Rangev2-Date-FindOneAndUpdate.yml.template

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11

22
# Requires libmongocrypt 1.8.0.
33
runOn:
4-
- minServerVersion: "7.0.0"
4+
- minServerVersion: "8.0.0"
55
# Skip QEv2 (also referred to as FLE2v2) tests on Serverless. Unskip once Serverless enables the QEv2 protocol.
66
# FLE 2 Encrypted collections are not supported on standalone.
77
topology: [ "replicaset", "sharded", "load-balanced" ]
8-
# Skip tests for "rangePreview" algorithm on Server 8.0+. Server 8.0 drops "rangePreview" and adds "range".
9-
maxServerVersion: "7.99.99"
108
database_name: &database_name "default"
119
collection_name: &collection_name "default"
1210
data: []
@@ -122,12 +120,6 @@ tests:
122120
"_id": 0,
123121
"encryptedDate": { $$type: "binData" },
124122
"__safeContent__": [
125-
{
126-
"$binary": {
127-
"base64": "5nRutVIyq7URVOVtbE4vM01APSIajAVnsShMwjBlzkM=",
128-
"subType": "00"
129-
}
130-
},
131123
{
132124
"$binary": {
133125
"base64": "RjBYT2h3ZAoHxhf8DU6/dFbDkEBZp0IxREcsRTu2MXs=",
@@ -183,12 +175,6 @@ tests:
183175
"_id": 1,
184176
"encryptedDate": { $$type: "binData" },
185177
"__safeContent__": [
186-
{
187-
"$binary": {
188-
"base64": "DLCAJs+W2PL2DV5YChCL6dYrQNr+j4p3L7xhVaub4ic=",
189-
"subType": "00"
190-
}
191-
},
192178
{
193179
"$binary": {
194180
"base64": "hyDcE6QQjPrYJaIS/n7evEZFYcm31Tj89CpEYGF45cI=",

0 commit comments

Comments
 (0)